Skip to content

Commit

Permalink
feat(proxy): add rewrite support for ws (#1407)
Browse files Browse the repository at this point in the history
Co-authored-by: wangwei <wangwei@qdcares.cn>
  • Loading branch information
vonweb and wangwei committed Jan 7, 2021
1 parent 3321111 commit fa3bc34
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/vite/src/node/server/middlewares/proxy.ts
Expand Up @@ -58,6 +58,9 @@ export function proxyMiddleware({
(opts.ws || opts.target?.toString().startsWith('ws:')) &&
req.headers['sec-websocket-protocol'] !== HMR_HEADER
) {
if (opts.rewrite) {
req.url = opts.rewrite(url)
}
proxy.ws(req, socket, head)
}
}
Expand Down

0 comments on commit fa3bc34

Please sign in to comment.