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

Update APP_URL to end in .localhost #333

Closed
wants to merge 1 commit into from
Closed

Conversation

kemp
Copy link

@kemp kemp commented Apr 12, 2024

While .test is convenient for developers using Laravel Valet, it provides an obstacle for users that don't. PR #240 improved this problem by first checking that the domain resolves correctly. My PR should improve this even further by not requiring DNS modifications for users that aren't using Valet while still allowing them to use my-app-name.localhost.

According to the W3 specification, domains ending in .localhost are intended to be treated specially, only resolving as loopback addresses. This means using .localhost will allow the browser to treat the site as a secure context, allowing developers to use features that would normally require HTTPS (such as the Geolocation API).

This does not break existing features because it only applies to new installations as well as keeps the canResolveHostname check with fallback to http://localhost in case the DNS resolution fails. In addition, developers using Valet can still use either .test or .localhost.

@kemp
Copy link
Author

kemp commented Apr 12, 2024

I'm going to make a few modifications to this PR. One flaw I believe is this will interfere with Valet's site mapping. I don't have a Mac to test at the moment unfortunately.

@kemp kemp marked this pull request as draft April 12, 2024 20:36
@driesvints
Copy link
Member

No plans for this sorry. .test is the default in Herd.

@driesvints driesvints closed this Apr 15, 2024
@kemp
Copy link
Author

kemp commented Apr 15, 2024

Thank you for your time. 👍

I'd still recommend considering falling back to <app-name>.localhost for installations that aren't using Valet or Herd (using the DNS check already used) because of the benefits mentioned in the original PR.

@jessarcher
Copy link
Member

Hey @kemp,

Thank you for teaching me that *.localhost is a thing!

Just wondering what are the benefits of <app-name>.localhost over just localhost for folks not using Herd/Valet? I assume it would be to support running multiple apps at the same time, but you'd still need a central web server on port 80 that could handle the hostname routing.

@kemp
Copy link
Author

kemp commented Apr 17, 2024

As you mentioned, to get multiple sites running you would still need a central web server/reverse proxy, so it's of no use there.

I'd say the main benefit and the reason I use <app-name>.localhost is to keep browser history separate and logins separate in my password manager. I'd say that helps me stay more organized compared to having all browsing history on localhost as well as my saved logins under the same domain.

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.

3 participants