I have service file like this .
service/http.ts
import axios from 'axios'
const config = useRuntimeConfig()
const http = axios.create({
baseURL: config.public.apiUrl,
})
export default http
and nuxt.config.js like this
export default defineNuxtConfig({
runtimeConfig: {
public: {
apiUrl: 'some value',
}
},
});
and .env like this
NUXT_API_URL=http://www.a.com/
and I want to access apiUrl here .
But it gives me an error.
also if I use process.env.NUXT_API_URL .
it gives an error again
so, how can I access env variable for my services file?