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

330
Views
Agregar el proxy en vite me lleva a esa URL de proxy en mi servidor local. Solo quiero usarlo para llamadas api al backend

Aquí está mi vite.config.ts:

 import { defineConfig } from 'vitest/config' import vue from '@vitejs/plugin-vue' import { quasar, transformAssetUrls } from '@quasar/vite-plugin' const path = require('path'); // https://vitejs.dev/config/ export default defineConfig({ test: { globals: true }, plugins: [ vue({ template: { transformAssetUrls } }), quasar({ sassVariables: 'src/assets/scss/quasar-variables.sass' }) ], resolve: { alias: { "@": path.resolve(__dirname, './src'), }, }, server: { proxy: { '/socket': { target: 'wss://abc-website.com:4221/', changeOrigin: true, ws: true, rewrite: (path) => path.replace('^/socket', ''), }, '/streaming/': { target: 'https://abc-website.com/', changeOrigin: true, }, '/': { target: 'https://abc-website.com/', changeOrigin: true, secure: false, ws: true }, } } })

cada vez que se carga mi aplicación, me lleva a https://abc-website.com mientras estoy en mi puerto locahost.

Quiero usar la URL anterior para las llamadas de API de back-end solo como https://abc-webite.com/api/auth .

También configuré la baseURL en "api/" después de configurar el proxy en vite.config.ts.

Además, después del ligero cambio, llama a la API REST como https://localhost:3000/auth, debería ser https://locahost:3000/api/auth

Vite proxy no parece funcionar correctamente para mí.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que podrías algo como esto:

 server: { proxy: { // ... your other proxies '/api': { target: 'https://abc-website.com/', changeOrigin: true, secure: false, ws: true, rewrite: (path) => path.replace(/^\/app/, ''), }, } }

Luego, todas sus solicitudes a sitios como localhost:3000/api/my-endpoint deben enviarse a https://abc-website.com/my-endpoint . No puede enviar todas las solicitudes "básicas", porque están reservadas para servir todo lo demás, todos los activos, index.html, etc., pero también soy amable

about 4 years ago · Juan Pablo Isaza Report
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!