[Vuejs]-Nuxt: Set origin on all Axios requests, depending on currenct domain

0👍

Finally figured it out.

I removed the plugin and instead I added onProxyReq method in the nuxt.config.js

proxy: {
  '/api/': {
    target: 'api.example.com',
    headers: {
      'origin': 'www.example.com',
      // ...
    },
    pathRewrite: {
      '^/api/': ''
    },
    onProxyReq: (proxyReq, req, res) => {
      proxyReq.setHeader('origin', 'www.example.com')
    }
  },
}
// ...

Leave a comment