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

🐛 BUG: wrangler dev strips port from Origin header when running with --host #8185

Open
aron opened this issue Feb 19, 2025 · 0 comments
Open
Labels
bug Something that isn't working

Comments

@aron
Copy link

aron commented Feb 19, 2025

Which Cloudflare product(s) does this pertain to?

Workers Runtime

What versions are you using?

3.109.2 [wrangler]

What operating system and version are you using?

macOS 13.5 (22G74)

Please provide a link to a minimal reproduction

https://gist.github.com/aron/cd013c56e5dd1205d385c3234e60da32

Describe the Bug

When running wrangler dev with the --host parameter the port is stripped from the Origin and Referer headers. This does not happen when running without the --host.

Example project: https://gist.github.com/aron/cd013c56e5dd1205d385c3234e60da32

export default {
	async fetch(request, env, ctx) {
		return new Response(
			`Host: ${request.headers.get('host')}\nOrigin: ${request.headers.get('origin')}\nReferer: ${request.headers.get('referer')}`,
		);
	},
};

The worker prints out the Host, Origin and Referer headers in a plain text response. The wrangler config is the default.

Steps to reproduce:

Without --host:

npx wrangler dev
curl http://localhost:8787 -H 'Origin: http://localhost:8787' -H 'Referer: http://localhost:8787/some/path'
Host: localhost:8787
Origin: http://localhost:8787
Referer: http://localhost:8787/some/path

Note

Both Origin and Referer include the port as expected.

With --host localhost:4000

npx wrangler dev --host localhost:4000
curl http://localhost:8787 -H 'Origin: http://localhost:8787' -H 'Referer: http://localhost:8787/some/path'
Host: localhost:4000
Origin: http://localhost
Referer: https://localhost/some/path

Note

Both Origin and Referer are missing the port.

Please provide any relevant error logs

No response

@aron aron added the bug Something that isn't working label Feb 19, 2025
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
Status: Untriaged
Development

No branches or pull requests

1 participant