$page.url.origin is set to https when a page is served over http
See original GitHub issueDescribe the bug
$page.url is not setto the actual URL of the page in adapter-node when served over http
Reproduction
<script>
import { page } from '$app/stores';
</script>
{$page.url.origin}
Use adapter-node, compile and serve the application withsvelte-kit build && node build
, load http://localhost:3000
in your browser.
expected: http://localhost:3000
actual: https://localhost:3000
System Info
latest sveltekit
Severity
serious, but I can work around it
Additional Information
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:22 (19 by maintainers)
Top Results From Across the Web
Understanding "same-site" and "same-origin" - web.dev
"Origin" is a combination of a scheme (also known as the protocol, for example HTTP or HTTPS), hostname, and port (if specified). For...
Read more >Same-origin policy - Web security | MDN
The same-origin policy is a critical security mechanism that restricts how a document or script loaded by one origin can interact with a ......
Read more >HTTPS and HTTP CORS - Stack Overflow
The origin's security protocol must match that of the requested URL. (http to http, https to https). If these do not match, the...
Read more >Maintaining separate HTTP and HTTPS requests to origin ...
On the Origins page, click the Attach a condition link next to the name of the non-secure server. · Fill out the Create...
Read more >Introduction to HTTPS
By default, when a user is on an HTTPS website and clicks a link to an HTTP website, browsers will not send a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
there’s no reason for it to be wrong on the server either, but y’all keep ignoring my great solution to that 🤣 https://github.com/sveltejs/kit/issues/3248#issuecomment-1008213529
That’s a valid point. So it does not make any sense to change anything on how the origin is set on the server-side. However we could overwrite the protocol in the start function of the renderer, right here: https://github.com/sveltejs/kit/blob/e881c7c57a3b136f92eba3aaef8952b11591a8e1/packages/kit/src/runtime/client/renderer.js#L162-L163
like this
This way $page.url.origin would be correct as soon as the start function has run. If no one is against this solution I’ll create a PR tomorrow.