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

SvelteKit RequestEvent.url.host(name) is undefined for https. This happens with the dev plugin. #4319

Closed
ivandimitrov8080 opened this issue Mar 13, 2022 · 1 comment
Milestone

Comments

@ivandimitrov8080
Copy link

ivandimitrov8080 commented Mar 13, 2022

Describe the bug

The req.headers.host in the code below found in kit/packages/kit/src/core/dev/plugin.js has a value of undefined when the server is https, but it works fine when it's http.

vite.middlewares.use(async (req, res) => {
    try {
        if (!req.url || !req.method) throw new Error('Incomplete request');

        const base = `${vite.config.server.https ? 'https' : 'http'}://${req.headers.host}`;

Reproduction

Create a new skeleton project and run the server using the --https flag:
HTTPS:
image
HTTP:
image

Logs

No response

System Info

System:
    OS: Linux 5.16 Arch Linux
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 12.85 GB / 15.48 GB
    Container: Yes
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 17.7.1 - /usr/bin/node
    npm: 8.5.4 - /usr/bin/npm
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.31 
    @sveltejs/kit: next => 1.0.0-next.295 
    svelte: ^3.44.0 => 3.46.4

Severity

blocking an upgrade

Additional Information

This propagates down to the event.url var on handle.

@benmccann benmccann added this to the 1.0 milestone Mar 14, 2022
@benmccann
Copy link
Member

#4362 was filed as a duplicate of this one. I'm going to keep that one though since it's had some more details added to it

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

No branches or pull requests

2 participants