question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

baseURL not working in asyncData

See original GitHub issue

It 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:open
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
DaDoBaagcommented, Sep 1, 2021

Have you tried setting browserBaseURL in publicRuntimeConfig?

0reactions
devzomcommented, Aug 31, 2021

Let’s try to set different config with public & private config “Options - Axios Module” https://axios.nuxtjs.org/options#baseurl

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found