Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when I use proxy with ws and bypass, server can't up #17973

Open
7 tasks done
hisland opened this issue Aug 29, 2024 · 1 comment · May be fixed by #18070
Open
7 tasks done

when I use proxy with ws and bypass, server can't up #17973

hisland opened this issue Aug 29, 2024 · 1 comment · May be fixed by #18070
Labels
p2-edge-case Bug, but has workaround or limited in scope (priority) regression The issue only appears after a new release

Comments

@hisland
Copy link
Contributor

hisland commented Aug 29, 2024

Describe the bug

when I use proxy with ws and bypass, server can't up

I tried [email protected] is ok, [email protected] is not ok and till now

Reproduction

https://stackblitz.com/edit/vitejs-vite-wuvxrc?file=vite.config.ts

Steps to reproduce

I create a new project use npm create vue
and set the base to '/aaa'
proxy / to a server , turn on ws: true, set bypass, and check the url is start of /aaa

import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'

// https://vitejs.dev/config/
export default defineConfig({
  base: '/aaa',
  plugins: [vue(), vueJsx()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    host: '0.0.0.0',
    port: 9099,
    proxy: {
      '/': {
        target: 'http://10.0.0.230:5193',
        secure: false,
        ws: true,
        bypass(req, res, options) {
          console.log('1111 /bypass: ', req.url)
          if (req.url?.startsWith('/aaa')) {
            console.log('111111 bypass: ', req.url)
            return req.url // do not proxy
          }
        }
      }
    }
  }
})

image

npm run dev and open browser to visit

server restart quickly, below is some screenshot
image

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (12) x64 Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz
    Memory: 4.46 GB / 23.84 GB
  Binaries:
    Node: 18.20.3 - C:\Program Files\nodejs\node.EXE
    npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
    bun: 1.1.25 - ~\.bun\bin\bun.EXE
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (127.0.2651.74)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @vitejs/plugin-vue: ^5.0.5 => 5.1.2
    @vitejs/plugin-vue-jsx: ^4.0.0 => 4.0.1
    vite: ^5.4.2 => 5.4.2

Used Package Manager

npm

Logs

No response

Validations

Copy link

stackblitz bot commented Aug 29, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@sapphi-red sapphi-red added p2-edge-case Bug, but has workaround or limited in scope (priority) regression The issue only appears after a new release labels Sep 10, 2024
@sapphi-red sapphi-red linked a pull request Sep 10, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-edge-case Bug, but has workaround or limited in scope (priority) regression The issue only appears after a new release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants