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: external redirects not being matched correctly closes #3770 #4109

Merged
merged 4 commits into from
Feb 4, 2022

Conversation

tinfoil-knight
Copy link
Contributor

@tinfoil-knight tinfoil-knight commented Jan 21, 2022

🎉 Thanks for submitting a pull request! 🎉

Summary

Fixes #3770

External redirects with status code >= 300 & <=400 were not proxied due to requests getting matched incorrectly. This PR fixes the issue by changing the order of matching so that external redirects get matched first.


For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures your code follows our style guide and
    passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

@tinfoil-knight
Copy link
Contributor Author

tinfoil-knight commented Jan 21, 2022

While working on the issue, I realized that external redirects don't follow the mentioned status code in the _redirects file and all of them have a 200 OK Status. I'm not sure if this is the expected behavior.

To reproduce, just add a redirects file as follows:

/foo https://www.netlify.com/ 299!

@tinfoil-knight tinfoil-knight changed the title test: add failing test to reproduce issue with 301 redirects fix: external redirects not being matched correctly Jan 21, 2022
@tinfoil-knight tinfoil-knight changed the title fix: external redirects not being matched correctly fix: external redirects not being matched correctly closes #3370 Jan 21, 2022
@tinfoil-knight tinfoil-knight changed the title fix: external redirects not being matched correctly closes #3370 fix: external redirects not being matched correctly closes #3770 Jan 21, 2022
@tinfoil-knight
Copy link
Contributor Author

tinfoil-knight commented Jan 24, 2022

Note: tests » framework-detection » should start custom command if framework=#custom, command and targetPort are configured is failing on Windows.

Update: Tests aren't failing consistently on all platforms making them hard to debug.

@erezrokah erezrokah added the type: bug code to address defects in shipped code label Jan 24, 2022
@erezrokah erezrokah force-pushed the fix/3770-external-redirects branch from 896f656 to 293a47f Compare February 4, 2022 12:52
Copy link
Contributor

@erezrokah erezrokah left a comment

Choose a reason for hiding this comment

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

This is great @tinfoil-knight 🚀

Sorry for the delay to review, and appreciate the test case!

@erezrokah erezrokah added the automerge Add to Kodiak auto merge queue label Feb 4, 2022
@kodiakhq kodiakhq bot merged commit 32714f0 into netlify:main Feb 4, 2022
@tinfoil-knight tinfoil-knight deleted the fix/3770-external-redirects branch February 4, 2022 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Add to Kodiak auto merge queue type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

External redirects don't work without 200 status
2 participants