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

chore: proxy bypass do nothing with object result #10209

Merged
merged 1 commit into from Nov 21, 2022

Conversation

PengBoUESTC
Copy link
Contributor

Description

if bypass return an object, 'viteProxyMiddleware' just handle the options and return directly

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@bluwy bluwy changed the title fix: proxy bypass do nothing with object result feat: proxy bypass do nothing with object result Sep 23, 2022
@sapphi-red
Copy link
Member

Maybe we could just remove this part for the following reason?

} else if (isObject(bypassResult)) {
Object.assign(options, bypassResult)
debug(`bypass: ${req.url} use modified options: %O`, options)
} else if (bypassResult === false) {

@PengBoUESTC
Copy link
Contributor Author

yes, i was just reading the source code and found this problem, I am not sure why there is no description in docs really. so maybe remove this part is reasonable

@sapphi-red sapphi-red added the p2-to-be-discussed Enhancement under consideration (priority) label Sep 23, 2022
@PengBoUESTC
Copy link
Contributor Author

Maybe we could just remove this part for the following reason?

} else if (isObject(bypassResult)) {
Object.assign(options, bypassResult)
debug(`bypass: ${req.url} use modified options: %O`, options)
} else if (bypassResult === false) {

any results ? +_+

@patak-dev
Copy link
Member

Hey @cisen, would you explain the context behind this PR?

Let's wait a bit, but I agree with @sapphi-red, if this wasn't working, better to remove this code in 3.2. We can add the feat once we have a real use case reported.

sla100
sla100 previously approved these changes Nov 12, 2022
@cisen
Copy link
Contributor

cisen commented Nov 17, 2022

Hey @cisen, would you explain the context behind this PR?

Let's wait a bit, but I agree with @sapphi-red, if this wasn't working, better to remove this code in 3.2. We can add the feat once we have a real use case reported.

#2421

@sapphi-red
Copy link
Member

I don't understand without any explanations, but by reading that PR, I guess this implementation was incomplete at the first place. So I think we could remove this.

@sla100
Copy link

sla100 commented Nov 18, 2022

So I think we could remove this.

Why remove useful functionality if it can be fixed with a simple change?

@sapphi-red
Copy link
Member

sapphi-red commented Nov 18, 2022

Because this wasn't working and not documented anywhere and nobody requested this feature.
I think we could fix this, if you want this. We should document this feature in that case.
But there might be more better solution for your requirements. Would you explain why you want this feature and why not by in another way?

@PengBoUESTC
Copy link
Contributor Author

So I think we could remove this.

Why remove useful functionality if it can be fixed with a simple change?

actually, there is no doc about bypass that with a true or Object result, so, may be we can remove this first, and then find a way to optimization it.

@sla100
Copy link

sla100 commented Nov 18, 2022

there is no doc about bypass

There is:

/**
* webpack-dev-server style bypass function
*/
bypass?: (
req: http.IncomingMessage,
res: http.ServerResponse,
options: ProxyOptions
) => void | null | undefined | false | string

@PengBoUESTC
Copy link
Contributor Author

I mean the Type of return value is void | null | undefined | false | string , no true or Object

@PengBoUESTC
Copy link
Contributor Author

@sapphi-red @patak-dev could U plz review for this .+_+

@patak-dev patak-dev changed the title feat: proxy bypass do nothing with object result chore: proxy bypass do nothing with object result Nov 21, 2022
@patak-dev
Copy link
Member

I agree with @sapphi-red here. And it looks like @cisen is pointing to a PR they did where they also removed this block: #2421. If someone needs this feature, let's get a proper issue or PR explaining the use case, documenting it, and adding tests.

@patak-dev patak-dev merged commit 934a304 into vitejs:main Nov 21, 2022
@patak-dev patak-dev added p1-chore Doesn't change code behavior (priority) and removed p2-to-be-discussed Enhancement under consideration (priority) labels Nov 21, 2022
fc pushed a commit to fc/vite that referenced this pull request Nov 23, 2022
@PengBoUESTC PengBoUESTC deleted the fix/proxy-bypass branch January 11, 2023 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p1-chore Doesn't change code behavior (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants