Use store value as header
yaki4 opened this issue · comments
Hi i would like to use a store value with onProxyReq.
But it seems that nuxt context or store is unavailable in proxy. Any ideas how to do it ?
I've tried req.body but it's undefined.
proxy: {
'/graphql': {
target: 'https://beautifulapigraph.com',
onProxyReq: function (proxyReq, req, res, options) {
proxyReq.setHeader('X-VAL', storeBasedValue)
}
}
},
This issue as been imported as question since it does not respect proxy-module issue template. Only bug reports and feature requests stays open to reduce maintainers workload.
If your issue is not a question, please mention the repo admin or moderator to change its type and it will be re-opened automatically.
Your question is available at https://cmty.app/nuxt/proxy-module/issues/c19.
@yaki4 Do not have access to the store here, you can take a look here nuxt/nuxt#2005
Hi! I have a problem, It's about onProxyReq
, It does not work when I set the custom header on request;
this is my nuxt config
proxy: {
'/proxy': {
target: 'http://localhost:3000',
pathRewrite: { '^/proxy/': '' },
onProxyReq(proxyReq) {
proxyReq.setHeader('X-Syl-Client-Token', 'foo')
},
},
},
I can't see it in Network in Chrome.
Could you please create a reproduction by using https://template.nuxtjs.org?