1

I'm using the Nuxt/Auth library in a NuxtJs project. I'm trying to make a login request to my backend. So I don't use any of the existing schemes that the library has prepared by default.

This is what my configuration looks like in nuxt.config.js

axios: {
    baseUrl: 'https://api.release.my-custom-domain.com',
    credentials: true,
    proxy: true
  },

  proxy: {
    '/api/': {
      target: 'https://api.release.my-custom-domain.com',
      pathRewrite: {'^/api/': ''}
    }
  },

  auth: {
    strategies: {
      local: {
        token: {
          property: 'token',
          global: true,
        },
        user: {
          property: 'user'
        },
        endpoint: {
          login: {url: '/api/v1/auth', method: 'post', propertyName: false}
        }
      }
    }
  },

I use a proxy because of a problem with cors.

This is what my code looks like in vue.

methods: {
    async loginFormSubmit () {
      try {
        let response = await this.$auth.loginWith('local', { data: this.login })
        console.log(response);
      } catch (err) {
        console.log(err);
      }
    }
  }

After I call the function, the XRH request runs, but it always adds /login to the url request.

This is what the url should look like - http://localhost:3000/api/auth

But the request looks like this - http://localhost:3000/api/auth/login

Didn't someone already solve this problem? Thank you for your answers.

0 Answers0