nuxt-community / axios-module

Secure and easy axios integration for Nuxt 2
https://axios.nuxtjs.org
MIT License
1.19k stars 245 forks source link

Plugin not using runtime variables from $config #386

Closed SkyaTura closed 4 years ago

SkyaTura commented 4 years ago

Version

v5.11.0

Reproduction link

https://codesandbox.io/s/pensive-joliot-og9ey

Steps to reproduce

What is expected ?

Try to get baseURL from $nuxt.$config.axios

What is actually happening?

Using only static compiled variable at build-time in <%= options.baseURL %>

Additional comments?

This would also solve #88

This bug report is available on Nuxt community (#c363)
gregjmcdonald commented 4 years ago

@SkyaTura Thank you for updating the module to use the new runtimeConfig! Am I right in thinking there is currently no way to consume a runtimeConfig variable for the proxy target alone?

My config consists of:

proxy: {
  '/api/': {
    target: process.env.API_URL,
    pathRewrite: { '^/api/': '' },
    changeOrigin: true,
    xfwd: true
  }
}

Thanks

IGassmann commented 4 years ago

@gregjmcdonald you'll find the answer to that here.