Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

339
Vistas
Nuxt : using proxy to access local API

I'm trying to setup an Oauth2 auth between my nuxt app and my PHP backend API.

Everything works fine until I try to fetch my user. I can't seem to configure my proxy right.

My api is https://api.local/api (on port 443)

My nuxt app is https://nuxt.local:8331

When I don't set any proxy, I have cors issues so I tried this :

modules: [
    '@nuxtjs/axios',
    '@nuxtjs/proxy',
    '@nuxtjs/auth-next'
  ],
  axios: {
    proxy: true
  },
  proxy: {
    '/api': {
      target: 'https://api.local',
      pathRewrite: {'^/api': '/api'},
      changeOrigin: true
    }
  },

my auth configuration :

auth: {
    redirect: {
      login: '/login',
      logout: '/logout',
      home: '/',
    },
    strategies: {
      my_strategy: {
        scheme: 'oauth2',
        endpoints: {
          authorization: 'https://api.local/oauth2/auth',
          token: 'https://api.local/oauth2/token',
          userInfo: '/api/me/profile',
          logout: 'https://api.local/oauth2/logout',
        },
        token: {
          property: 'access_token',
          type: 'Bearer',
          maxAge: 1800
        },
        refreshToken: {
          property: 'refresh_token',
          maxAge: 60 * 60 * 24 * 30
        },
        responseType: 'code',
        codeChallengeMethod: 'S256',
        grantType: 'authorization_code',
        accessType: undefined,
        redirectUri: process.env.OAUTH2_REDIRECT_URI,
        logoutRedirectUri: undefined,
        clientId: process.env.API_KEY,
        scope: [],
      }
    }

But when I call this.$auth.fetchUser() (when the token is set) I get this error :

Error occured while trying to proxy: nuxt.local:8331/api/me/profile

What am I doing wrong here ?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda