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

Astro.url.protocol returning http event when in https #5890

Closed
1 task
GaspardCulis opened this issue Jan 18, 2023 · 8 comments · Fixed by #5992
Closed
1 task

Astro.url.protocol returning http event when in https #5890

GaspardCulis opened this issue Jan 18, 2023 · 8 comments · Fixed by #5992

Comments

@GaspardCulis
Copy link

What version of astro are you using?

8.19.3

Are you using an SSR adapter? If so, which one?

Node adapter, standalone

What package manager are you using?

npm

What operating system are you using?

Arch Linux btw

Describe the Bug

In the --- ... --- zone (how do you call it ?) of an Astro page, I'm trying to access the current URL origin of my page using Astro.url.origin. It returns the good domain name, but prefixed with http, not https (I started my preview server with SERVER_KEY_PATH & SERVER_CERT_PATH env variables, https works fine in the browser). Same issue for Astro.url.protocol.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-8d8wxa?file=src%2Fpages%2Findex.astro,package.json&on=stackblitz

Participation

  • I am willing to submit a pull request for this issue.
@MoustaphaDev
Copy link
Member

@GaspardCulis I believe you need to use the node adapter and have SSR enabled in your astro config

@GaspardCulis
Copy link
Author

I said in the issue I was using the node adapter, here is my config :

export default defineConfig({
output: 'server',
adapter: node({
mode: 'standalone',
}),
vite: {
optimizeDeps: {
exclude: ['postgres'],
},
},
});

@MoustaphaDev
Copy link
Member

I said in the issue I was using the node adapter, here is my config :

export default defineConfig({ output: 'server', adapter: node({ mode: 'standalone', }), vite: { optimizeDeps: { exclude: ['postgres'], }, }, });

Ah I completely skipped it, I saw the repro didn't have it.

@MoustaphaDev
Copy link
Member

MoustaphaDev commented Jan 18, 2023

Maybe try setting the vite config's server.https option to true?

@GaspardCulis
Copy link
Author

GaspardCulis commented Jan 19, 2023

Haven't configured that on codeblitz sorry did it quick and dirty.
I changed my config:

export default defineConfig({
	output: 'server',
	adapter: node({
		mode: 'standalone',
	}),
	vite: {
		optimizeDeps: {
			exclude: ['postgres'],
		},
		server: {
			https: true,
		},
	},
});

I was sure this would solve my issue, but it didn't sadly. So might be a bug / missing feature.

@rishi-raj-jain
Copy link
Contributor

Yeah, I'm experiencing the same, hence switched to https://github.com/rishi-raj-jain/rishi.app/blob/master/src/pages/api/search.js#L4 checks.

@rishi-raj-jain
Copy link
Contributor

Maybe we can do a config variable to set the protocol and hostname.

@GaspardCulis
Copy link
Author

Yeah, I mean I found an alternative to know which protocol my website is using, I just reported this issue because it seems like a bug that could be fixed

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 a pull request may close this issue.

3 participants