-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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(serve): check the 'Accept' header in the request before transform (fix #3502) #14121
Conversation
Run & review this pull request in StackBlitz Codeflow. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
It appears that some tests have not passed. What should I do to address this? |
qwik's fail is expected. But other fails seems to be caused by this PR. |
marko fails with main branch so I guess that fail isn't related to this PR as well. |
After using vite-plugin-html, this issue can be avoided, so close this PR. |
Description
this PR fix #3502
Additional context
For a project started in Vite's serve mode:
a. If there is a folder named "foo" with a package.json inside it in the root directory.
b. If there is a JavaScript file named "bar.js" in the root directory.
When accessing http://localhost:3000/foo or http://localhost:3000/bar, it will result in an error.
Here's a very simple example for any project started with Vite's serve mode, when accessing http://localhost:3000/vite.
Assuming my project has a route /vite, this will not give me the expected result.
This is because Vite does not check the source of the request during transformation. Considering the address entered in the browser's address bar, there no need for transformation; it should directly return the page itself. When a user directly enters an address in the browser, the Accept header will always include the "text/html" field. Therefore, in this pull request, we use the "Accept" header with "text/html" to make this determination.
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).Submitted with StackBlitz Codeflow.