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

fix: websocket proxies not the same as http #4893

Merged
merged 3 commits into from
Sep 16, 2021
Merged

Conversation

mikeplus64
Copy link
Contributor

Description

Currently WebSocket proxies cannot use a regex like with HTTP ones -- this PR makes WS and HTTP have the same behaviour for matching URLs. Seems like just something that was missed when initially adding regex support for proxies.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

@@ -116,3 +115,10 @@ export function proxyMiddleware(
next()
}
}

function testUrl(url: string, target: string) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"test" seems a bit ambiguous here or maybe doesn't describe what this function does that clearly. Is this test as in RegExp.test? Or are these URLs used for testing? Maybe there could be a better name for this function that describes what it's checking for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the quick review, is doesProxyContextMatchUrl ok? 437457d

@patak-dev patak-dev merged commit 9260848 into vitejs:main Sep 16, 2021
@patak-dev
Copy link
Member

Thanks for the PR @mikeplus64, it would be good if we could get some tests added to the playground in case you see a reliable way to test this and other related functionality

aleclarson pushed a commit to aleclarson/vite that referenced this pull request Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants