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

PORT in URL address in production (Astro.url) #12192

Closed
1 task
Fakerko opened this issue Oct 11, 2024 · 11 comments · Fixed by #12197
Closed
1 task

PORT in URL address in production (Astro.url) #12192

Fakerko opened this issue Oct 11, 2024 · 11 comments · Fixed by #12197
Labels
- P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) regression

Comments

@Fakerko
Copy link

Fakerko commented Oct 11, 2024

Astro Info

Astro v4.16.0
@astrojs/node v8.3.4

Node v20.17.0

The bug is in production on domain assigned.

If this issue only occurs in one browser, which browser is a problem?

Tested in Chrome

Describe the Bug

When I call Astro.url, Astro.url.href, Astro.url.host and Astro.url.origin return the URL in the format:

http(s)://www.example.com:PORT

Which is correct in a development environment, but not in production.
In a previous version of Astro, I tested Astro v4.15.7, the URL did not include PORT in production.

Reproduced code example in production: https://www.palocko.cz/test

I think it's related to: #12130

What's the expected result?

In production it should not contain the PORT after domain.

So instead of http(s)://www.example.com:PORT it should be http(s)://www.example.com

As mentioned here: https://docs.astro.build/en/reference/api-reference/#astrourl

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-7rspdv?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Oct 11, 2024
@matthewp matthewp added - P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) regression and removed needs triage Issue needs to be triaged labels Oct 11, 2024
@ematipico
Copy link
Member

Hi @Fakerko, can I ask you to try astro@experimental--astro-url-fix and report if this version fixes your app?

@Fakerko
Copy link
Author

Fakerko commented Oct 11, 2024

Hi @ematipico, I tried, but was not able to test it because the production environment ended on error see screenshot.

Snímek obrazovky 2024-10-11 v 16 47 59

@matthewp
Copy link
Contributor

Hey @Fakerko, what version of Node.js are you using?

@matthewp
Copy link
Contributor

matthewp commented Oct 12, 2024

If you do:

> new Request('http://example.com:80/url').url
'http://example.com/url'

The port gets stripped when you call new Request. I tried in several versions of Node and always saw that. Given that, I'm not sure how it's possible that e96bcae is the cause of this bug.

@Fakerko
Copy link
Author

Fakerko commented Oct 12, 2024

@matthewp Hi, I am using v20.17.0 on the production server.

The problem is that I didn't edit anything on the site, I only updated from Astro version 4.15.7 to 4.16.0 and the URLs were wrong.

@Fakerko
Copy link
Author

Fakerko commented Oct 12, 2024

@matthewp Just tested, that the last working version is Astro v4.15.12. After update to v4.16.0 or v4.16.2 the problem appear.

@Fakerko
Copy link
Author

Fakerko commented Oct 12, 2024

@matthewp I disabled cache on the site https://www.palocko.cz/test do you see the port is changing every time on page reload? I think this is not normal.

@ematipico
Copy link
Member

@Fakerko we just released a patch (v4.16.3) that should fix your regression. Could you please test it and report back to us?

@Fakerko
Copy link
Author

Fakerko commented Oct 14, 2024

@ematipico It fixed the issue! Working as expected now. Thank you.

@matthewp
Copy link
Contributor

@Fakerko what port number were you seeing?

@Fakerko
Copy link
Author

Fakerko commented Oct 14, 2024

@matthewp Now I don't see any port anymore. Before I always saw a random 5 digit port.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants