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

332
Vistas
Adding the proxy in vite takes me to that proxy url on my localhost. I only want to use it for api calls to backend

Here is my 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
      },
    }
  }
})

whenever my application is loaded it takes me to the https://abc-website.com while being on my locahost port.

I want to use above url for backend api calls only like https://abc-webite.com/api/auth.

Also i set the baseURL to "api/" after setting the proxy in vite.config.ts.

Also after the slight change it calls the REST api like https://localhost:3000/auth, i should rather be https://locahost:3000/api/auth

Vite proxy doesn't seems to work properly for me.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think you could something like this:

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

Then all your requests to sites like localhost:3000/api/my-endpoint should be proxied to https://abc-website.com/my-endpoint. You cannot proxy all "basic" requests, 'cause they are reserved for serving everything else, all the assets, index.html's and etc., but I'm also kind

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