Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use store value as header #30

Open
yaki4 opened this issue Feb 18, 2019 · 4 comments
Open

Use store value as header #30

yaki4 opened this issue Feb 18, 2019 · 4 comments

Comments

@yaki4
Copy link

yaki4 commented Feb 18, 2019

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 question is available on Nuxt community (#c19)
@ghost ghost closed this as completed Feb 18, 2019
@ghost ghost added the cmty:question label Feb 18, 2019
@ghost
Copy link

ghost commented Feb 18, 2019

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.

@ricardogobbosouza
Copy link
Member

@yaki4 Do not have access to the store here, you can take a look here nuxt/nuxt#2005

@pi0 pi0 reopened this Mar 23, 2019
@mistricky
Copy link

mistricky commented Oct 23, 2019

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.

Copy link
Member

atinux commented Jan 29, 2021

Could you please create a reproduction by using https://template.nuxtjs.org?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants