Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

341
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda