baseURL not working in asyncData
See original GitHub issueIt seems that baseURL is not working in asyncData. Requests always sent to localhost.
nuxt.config.js
modules: [
'@nuxtjs/axios',
'@nuxtjs/auth-next',
],
axios: {
baseURL: 'http://localhost:8000',
},
pages/index.vue
async asyncData({ params, $axios, $auth }) {
const courses = await $axios.$get(
`api/students/${$auth.id_slug}/enrollments/`
)
return { courses }
},
Would be good if anyone could shred some light on this. This is supposed to be a very simple one i am guessing… Not sure what I missed
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
Nuxt.Js axios not using baseURL despite it being set correctly
Problem : Axios is still making the request on http://localhost:3000 if I do a console.log($axios.defaults.baseURL) the correct baseURL of my ...
Read more >Moving from @nuxtjs/dotenv to runtime config
It's time to migrate from @nuxtjs/dotenv module to use our new runtime config which has been released as of Nuxt v2.13. What are...
Read more >Nuxt configuration file
Nuxt configuration file. By default, Nuxt is configured to cover most use cases. This default configuration can be overwritten with the nuxt.config.js file....
Read more >nuxt-community - Bountysource
It seems that baseURL is not working in asyncData. Requests always sent to localhost. nuxt.config.js modules: [ '@nuxtjs/axios', '@nuxtjs/auth- ...
Read more >Nuxt asyncData (using Fetch API from same server, configure ...
Nuxt with asyncData; Use Fetch API instead of Axios ... is not necessary as client could always resolve server base url /* if...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Have you tried setting browserBaseURL in publicRuntimeConfig?
Let’s try to set different config with public & private config “Options - Axios Module” https://axios.nuxtjs.org/options#baseurl