solidjs / solid-start

SolidStart, the Solid app framework
https://start.solidjs.com
MIT License
5.18k stars 375 forks source link

[Bug?]: event.request in entry-server is getting a url with a wrong protocol (i.e. http instead of https) #938

Closed lominming closed 10 months ago

lominming commented 1 year ago

Duplicates

Latest version

Current behavior 😯

Using a fresh solid-start installation, entry-server itself gets the wrong protocol of the url. No matter whether I am accessing from https, the url will always be http.

Give this code, and I visit https://example.com/test <--- note that it is HTTPS

import {
  createHandler,
  renderAsync,
  StartServer,
} from "solid-start/entry-server";

export default createHandler(
  renderAsync((event) => {
    console.log(event.request.url);
    return <StartServer event={event} />;
  })
);

The output for console log is http://example.com/test <--- note that this becomes HTTP

I am unclear whether this is (A) expected behavior, but I am not understanding the way it works (B) a bug (C) a configuration I missed on vite

Expected behavior 🤔

Expect the console log to include HTTPS i.e. https://example.com/test

Steps to reproduce 🕹

Steps:

  1. Install solid-start
  2. Add console log on entry-server

Context 🔦

Why this matters:

Your environment 🌎

Packages:
    "solid-js": "^1.7.2",
    "solid-start": "^0.2.26",
    "@auth/core": "^0.9.0",
    "@auth/solid-start": "^0.1.1",
JesusP2 commented 1 year ago

I tried to reproduce the problem, deployed it to vercel but It seems to work fine.

Where are you deploying it or how are you testing the https server?

lominming commented 1 year ago

@JesusP2 On further investigation, it is a very curious situation. I was wondering whether I am missing some proxy setup in Vite?

1) The actual prod env that I am facing this issue is Solid Start Vite project in Docker image, deployed to AWS ECS. (https gone within entry-server)

GET https://mywebsite.com/
IN ENTRY SERVER http://mywebsite.com/

2) With a fresh install of solid-start, together with @vitejs/plugin-basic-ssl to get https on localhost, I get the following (becomes undefined?).

GET https://localhost:3000/
IN ENTRY SERVER http://undefined/

3) If I use ngrok to proxy, when I hit http://1234-11-22-33-44.ngrok-free.app, I get (https gone):

GET https://localhost:3000/
IN ENTRY SERVER http://1234-11-22-33-44.ngrok-free.app/

4) Check out this codesandbox: https://codesandbox.io/p/sandbox/solid-start-experimental-forked-rt5ntz (should be https too):

GET http://localhost:3000/
IN ENTRY SERVER http://rt5ntz-3000.csb.app/

I think there's some obvious proxy related setting somewhere? This feels like a Vite config related issue, but not apparently clear which one is the correct config. It could be server.proxy but unclear.

// Code for SSL on localhost
import solid from "solid-start/vite";
import { defineConfig } from "vite";
import basicSsl from '@vitejs/plugin-basic-ssl'

export default defineConfig({
  plugins: [solid(), basicSsl()],
});
ryansolid commented 10 months ago

In setting up for SolidStarts next Beta Phase built on Nitro and Vinxi we are closing all PRs/Issues that will not be merged due to the system changing. If you feel your issue was closed by mistake. Feel free to re-open it after updating/testing against 0.4.x release. Thank you for your patience.

See https://github.com/solidjs/solid-start/pull/1139 for more details.