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: createActionURL set detectedProtocol correctly #10421

Merged
merged 2 commits into from Mar 31, 2024

Conversation

Carlos-err406
Copy link
Contributor

@Carlos-err406 Carlos-err406 commented Mar 27, 2024

☕️ Reasoning

the newest implementation of createActionURL occasionally throws ERR_INVALID_URL because of double colons in protocol

this fix just checks if the detectedProtocol ends with a colon, and if not it adds it before creating the url with the detected host

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

Fixes: #10408

📌 Resources

Copy link

vercel bot commented Mar 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 31, 2024 3:03am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Mar 31, 2024 3:03am

Copy link

vercel bot commented Mar 27, 2024

@Carlos-err406 is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added the core Refers to `@auth/core` label Mar 27, 2024
@Carlos-err406 Carlos-err406 changed the title Main Fix: possible invalid URL in createActionURL Mar 27, 2024
@ThangHuuVu
Copy link
Member

Could you add a test for it? Thanks for catching!

@adainrivers
Copy link

URL.protocol always ends with colon:

https://developer.mozilla.org/en-US/docs/Web/API/URL/protocol

@Carlos-err406
Copy link
Contributor Author

Could you add a test for it? Thanks for catching!

will do!

@Carlos-err406
Copy link
Contributor Author

@ThangHuuVu what do you think?

Copy link
Member

@ndom91 ndom91 left a comment

Choose a reason for hiding this comment

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

Tests pass, LGTM 👍

Althoguh it looks like x-forwarded-proto is usually sent without : (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto), but shuold work either way.

@ndom91 ndom91 changed the title Fix: possible invalid URL in createActionURL fix: createActionURL set detectedProtocol correctly Mar 30, 2024
@Carlos-err406
Copy link
Contributor Author

Tests pass, LGTM 👍

Althoguh it looks like x-forwarded-proto is usually sent without : (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto), but shuold work either way.

true, there is a test that could be erased

packages/core/test/env.test.ts Outdated Show resolved Hide resolved
packages/core/test/env.test.ts Outdated Show resolved Hide resolved
@ThangHuuVu
Copy link
Member

@Carlos-err406 could you please apply the tests changes suggested, as x-forwarded-proto is usually sent without : like @ndom91 said, I could not apply myself due to your PR is from your main branch

Copy link

codecov bot commented Mar 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 39.48%. Comparing base (11cfb0a) to head (a751183).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10421   +/-   ##
=======================================
  Coverage   39.48%   39.48%           
=======================================
  Files         171      171           
  Lines       27320    27321    +1     
  Branches     1168     1169    +1     
=======================================
+ Hits        10786    10787    +1     
  Misses      16534    16534           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ThangHuuVu ThangHuuVu merged commit 246a838 into nextauthjs:main Mar 31, 2024
12 of 14 checks passed
JipSterk pushed a commit to JipSterk/next-auth that referenced this pull request Apr 3, 2024
…js#10421)

* fix: possible invalid url in createActionURL

* fix: x-forwarded-proto goes without colon
JipSterk pushed a commit to JipSterk/next-auth that referenced this pull request Apr 3, 2024
…js#10421)

* fix: possible invalid url in createActionURL

* fix: x-forwarded-proto goes without colon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Refers to `@auth/core`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ERR_INVALID_URL
4 participants