Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

338
Views
Nuxt: uso de proxy para acceder a la API local

Estoy tratando de configurar una autenticación Oauth2 entre mi aplicación nuxt y mi API backend de PHP.

Todo funciona bien hasta que intento buscar a mi usuario. Parece que no puedo configurar mi proxy correctamente.

Mi api es https://api.local/api (en el puerto 443)

Mi aplicación nuxt es https://nuxt.local:8331

Cuando no configuro ningún proxy, tengo problemas de cors, así que probé esto:

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

mi configuración de autenticación:

 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: [], } }

Pero cuando llamo a this.$auth.fetchUser() (cuando el token está configurado) aparece este error:

Ocurrió un error al intentar usar el proxy: nuxt.local:8331/api/me/profile

Qué estoy haciendo mal aquí ?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!