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: Correctly set x-ms-original-url to the full original request URL (#286) #314

Merged
merged 6 commits into from
Oct 15, 2021

Conversation

danielgary
Copy link
Contributor

@danielgary danielgary commented Sep 27, 2021

Resolves #286

Original issue:
In production, the x-ms-original-url header is set to the full, original request URL, so fallback functions can correctly handle every request. When using this CLI, x-ms-original-url was set to the rewrite path instead so functions could not tell what route they were supposed to be handling.

Here's what's changed:

  • The x-ms-original-url is always set to the full, original request URL
  • If x-ms-original-url is already set in injectHeaders, don't overwrite it
  • getResponse now returns a boolean to indicate if the request was successfully handled or not
  • If getResponse returns false, fall back to serveStaticOrProxyResponse

@danielgary
Copy link
Contributor Author

Hi @anthonychu, this should resolve the issue with Remix running in dev and should correctly replicate how x-ms-original-url works in production.

@danielgary danielgary changed the title 286 rewrite paths fix: 286 rewrite paths Sep 28, 2021
@danielgary
Copy link
Contributor Author

I refactored the getResponse method to return a boolean if it was succesfully handled.

I believe this is a better implementation than the previous one. Please let me know if any changes need to be made.

@manekinekko manekinekko added scope: msha Issues happened a the ./src/msha level scope: rules engine Specific issues related to src/msha/routes-engine/** status: need internal approval The issue need an internal approval from a stakeholder before it gets addressed labels Oct 1, 2021
@manekinekko
Copy link
Member

Thank you @danielgary for taking the time to investigate this issue. May I ask you to make two changes:

  • add new unit tests and e2e tests to make sure we don't have any regression in the future.
  • update your commit message based on our contributing guidelines.

@danielgary danielgary changed the title fix: 286 rewrite paths fix: Correctly set x-ms-original-url to the full original request URL (#286) Oct 1, 2021
@github-actions github-actions bot removed scope: msha Issues happened a the ./src/msha level status: need internal approval The issue need an internal approval from a stakeholder before it gets addressed scope: rules engine Specific issues related to src/msha/routes-engine/** labels Oct 1, 2021
@danielgary
Copy link
Contributor Author

Thanks for the feedback @manekinekko

I've updated the message and also added an E2E test.

@manekinekko manekinekko added scope: msha Issues happened a the ./src/msha level scope: rules engine Specific issues related to src/msha/routes-engine/** status: need internal approval The issue need an internal approval from a stakeholder before it gets addressed labels Oct 1, 2021
@danielgary
Copy link
Contributor Author

Any updates on this? This is the only issue preventing Remix from including Azure SWA support out of the box.

@manekinekko
Copy link
Member

I am sorry about the delay @danielgary, we were expecting to sync with other stakeholders on this change.

I am gonna skip team validation, and approve your changes to unblock you. We'd love to have the CLI support Remix based on your work.

Thank you again for your contribution 🎉

@manekinekko manekinekko merged commit 0ea7146 into Azure:main Oct 15, 2021
@danielgary
Copy link
Contributor Author

Awesome! I already pinged the Remix team and I know they are looking forward to this being released!

@danielgary danielgary deleted the 286-rewrite-paths branch October 15, 2021 16:06
@manekinekko
Copy link
Member

Great! Looking forward to it ☺️

@garand
Copy link
Contributor

garand commented Nov 12, 2021

@manekinekko Thanks for getting this merged in! Curious what your release cycle is and when we could expect a new release containing this change.

@sgollapudi77
Copy link
Contributor

Hi @garand we're doing a release every month or so depending on the number of commits. So, following that we'll be doing a new release in less than a week. :)

@sgollapudi77
Copy link
Contributor

Hi @garand we released a new version today with small fixes including the fix for this change. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: msha Issues happened a the ./src/msha level scope: rules engine Specific issues related to src/msha/routes-engine/** status: need internal approval The issue need an internal approval from a stakeholder before it gets addressed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rewrites in development have incorrect path Using a function as a fallback route doesn't work
4 participants