-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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[dev-server]: Fix html file matching from URL #9347
FIX[dev-server]: Fix html file matching from URL #9347
Conversation
384f3c3
to
e8d1608
Compare
Hey @mischnic, Need your review of this PR. |
The tests are failing |
a5b2d56
to
376ed20
Compare
Please don't change any existing tests, those are there for a reason and need to pass still. |
For the above folder 👆 and If we look at this line, We find for The same goes for the others like this Just wondering if that is the expected behaviour. |
No, the existing tests are correct. For a SPA-style app with client-side routing, unknown routes need to return the index page. To fix #9211, it might be enough to just remove the |
Oh okay. Then I will make the required changes |
376ed20
to
f47bfcb
Compare
Added the changes. Thanks for helping me out all the way 😃 . |
Integration test is failing in
Don't think this is related to my changes. |
Yeah that's fine, you can ignore that. The tests are flakey. |
@@ -196,6 +196,12 @@ export default class Server { | |||
}); | |||
|
|||
let indexFilePath = null; | |||
let {pathname: reqURL} = url.parse(req.originalUrl || req.url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like previously it only looked at req.url
, is there a reason why you added originalUrl
?
I remember that we had problems with req.originalUrl
in the past if you use the proxy in front of the dev server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wanted to make sure we are using the same pathname everywhere like here.
Co-authored-by: Tanmoy Bhowmik <tbhowmik2@atlassian.com>
* Fix parcel-query * Modify parcel-query to not require all graphs on start * Make flow happy * Initial fix for inspectCache * Modify fix for inspectCache * Remove unused requestTypes * FIX[dev-server]: Fix html file matching from URL (#9347) Co-authored-by: Tanmoy Bhowmik <tbhowmik2@atlassian.com> * Modify inspectCache to give info when not all graphs present --------- Co-authored-by: Tanmoy Bhowmik <tanmoy.openroot@gmail.com> Co-authored-by: Tanmoy Bhowmik <tbhowmik2@atlassian.com>
Closes #9211
↪️ Pull Request
In this PR we rethink how we server the HTML bundle for a given URL in the dev server.
💻 Examples
We get all the
htmlBundleFilePaths
and sort them based on/
(depth)Example:
For URL
/other
and let's say we have sorted htmlBundleFilePaths as['/other.html', 'other/index.html' ]
So for
/other
URL should be served with/other.html
file.And if we have sorted htmlBundleFilePaths as
['other/index.html' ]
For
/other
URL should be served with/other/index.html
file.🚨 Test instructions
Extend the
html
example(packages/examples/HTML).Create multiple directories like
Add source and dev command in
package.json
Run yarn run dev to use the local dev server.
Expected Behavior
/other?foo=bar
correctly returns the content ofpackages/examples/html/src/other.html
/other.html?foo=bar
correctly returns the content ofpackages/examples/html/src/other.html
/other
correctly returns the content ofpackages/examples/html/src/other.html
/other.html
correctly returns the content ofpackages/examples/html/src/other.html
/other/other?foo=bar
correctly returnspackages/examples/html/src/other/other.html
/other/other
correctly returnspackages/examples/html/src/other/other.html
/other/index
correctly returnspackages/examples/html/src/other/index.html
✔️ PR Todo