Is it possible in SvelteKit to get protocol of current page (HTTP or HTTPS)?
Something like:
import {page} from '$app/stores';
console.log($page.protocol);
So far, I only see:
{
host: 'localhost:3000',
path: '/projektDetalji',
query: URLSearchParams { 'id' => '1' },
params: {}
}
You could use browser
to make sure you are running in browser, then grab protocol from window.location.protocol
.
<script context="module">
import { browser } from "$app/env"
if (browser) {
console.log(window.location.protocol);
}
</script>
From $app/env
module section of sveltekit docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With