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

Allow passthrough redirects #125

Merged
merged 1 commit into from
Feb 19, 2021
Merged

Allow passthrough redirects #125

merged 1 commit into from
Feb 19, 2021

Conversation

vorillaz
Copy link
Contributor

Description

Allow absolute URL redirects when applicable. Closes #124 .

Checklist

index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
@@ -31,6 +31,10 @@ function waitConnection (socket, write) {
}
}

function isExternalUrl (url = '') {
return urlPattern.test(url)
Copy link
Member

Choose a reason for hiding this comment

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

Would you mind to check if url.startsWith('http://') || url.startsWith('https://') is faster than regex?

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@vorillaz
Copy link
Contributor Author

vorillaz commented Jan 1, 2021

Awesome, happy new year @mcollina. Waiting for this one getting merged :D

@@ -31,6 +31,10 @@ function waitConnection (socket, write) {
}
}

function isExternalUrl (url = '') {
return urlPattern.test(url)
Copy link
Member

Choose a reason for hiding this comment

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

How is this guaranteed to be "an external url"? Shouldn't the headers be inspected to determine if there is a 3xx code that should be honored?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was my initial thought but status code is not getting passed through the rewriteHeaders method

Copy link
Member

Choose a reason for hiding this comment

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

Then I would think the solution starts with resolving that issue. I do not see how this simple test is a guarantee of a redirect.

Copy link
Member

Choose a reason for hiding this comment

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

If status code is necessary for the checking, I think you can start a PR in fastify-reply-form to achieve it.

@mcollina
Copy link
Member

any updates on this?

@vorillaz
Copy link
Contributor Author

I am not sure I can merge this one as there are no action items, I resolved all the issues but merging is blocked and I don't know why.

@jsumners
Copy link
Member

I am not sure I can merge this one as there are no action items, I resolved all the issues but merging is blocked and I don't know why.

Merging is not blocked, per se. I would certainly like my question addressed, but I'm not blocking this.

@csvan
Copy link

csvan commented Feb 17, 2021

@vorillaz could you try merging this again if nothing is blocking?

@mcollina mcollina merged commit 2261cdb into fastify:master Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fastify-http-proxy does not respect 302 redirects
6 participants