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

cookie is sent only to my localhost http api, but not to my productive api running on https #45

Closed
tobkle opened this issue Oct 14, 2017 · 2 comments

Comments

@tobkle
Copy link

tobkle commented Oct 14, 2017

Calling my development microservices with http://localhost/api the credentials cookies are sent. Setting it to production to run against https://api.server/api it doesn't send the cookies any more.

First I thought it was due to this, but by deactivating it in "plugin.template.js" it is still not working:

  axios.interceptors.request.use(config => {
    // if (config.withCredentials === undefined) {
      // if (!/^https?:\/\//i.test(config.url) || config.url.indexOf(baseURL) === 0) {
        config.withCredentials = true
      // }
    // }
    return config
  });

Can anyone give me a hint how you are calling your microservices api?

This question is available on Nuxt.js community (#c42)
@pi0
Copy link
Member

pi0 commented Oct 14, 2017

Hi. While my answer would not be exactly your question, but i HIGHLY recommend using proxy module for your microservice deployments as it resolves problems with credentials and CORS. A little guide on usage is at the end of docs.

About your question: I think CORS header should be enabled to make XHR working ...

@tobkle
Copy link
Author

tobkle commented Oct 14, 2017

Thanks for your fast valuable hint. It works with the following setup:

nuxt.config.js

...
modules: [
  '@nuxtjs/auth',
  '@nuxtjs/axios',
  '@nuxtjs/proxy'
],

axios: {},

proxy: {
    '/api': 'https://api.server.org'
},
...

Starting nuxt:
nuxt:axios BaseURL: http://localhost:3333/api (Browser: /api) +0ms
[HPM] Proxy created: /api -> https://api.server.org

'/api/auth/login' results now into 'https://api.server.org/api/auth/login'

Cookies are transferred as expected.

@tobkle tobkle closed this as completed Oct 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants