-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
https option not working in svelte-kit next.236 #3479
Comments
I'm being hit with this error as well trying to use |
I think it has to do with HTTP2, since HTTP2 headers can have colons |
Same error with SvelteKit 1.0.0-next.239 and newer node version... System: Steps to reproduce: npm init svelte@next my-app
cd my-app
npm install
npm run dev -- --open --https |
@joshnuss - I think you are correct as I can confirm in Chrome that the failed request was made via HTTP/2: |
This is an acute problem for developers on macOS trying to test Safari. Safari converts requests for resources like images to HTTPS even if the href is a relative URL. The only way to successfully test a SvelteKit app on Safari on Monterey (12.1) is to use |
That's precisely it. http2 pseudo-headers. Request can't receive headers with those. The problem is that on getRequest(base, req), a Http2ServerRequest is converted to a Request, and headers are incompatible. Can we can just strip those headers for now?. I don´t know if use them to infer the correct url/method of the Request object is something adequate. diff --git a/packages/kit/src/node.js b/packages/kit/src/node.js
index 44d3ae38..ff316632 100644
--- a/packages/kit/src/node.js
+++ b/packages/kit/src/node.js
@@ -52,9 +52,14 @@ function get_raw_body(req) {
/** @type {import('@sveltejs/kit/node').GetRequest} */
export async function getRequest(base, req) {
+ const headers = Object.fromEntries(
+ Object.entries(/** @type {Record<string, string>} */ (req.headers)).filter(
+ ([key]) => !/^:/.test(key)
+ )
+ );
return new Request(base + req.url, {
method: req.method,
- headers: /** @type {Record<string, string>} */ (req.headers),
+ headers,
body: await get_raw_body(req) // TODO stream rather than buffer
});
} |
I'm wondering if filtering pseudo-headers will be enough. We may also need to convert the response to http2 (not sure). Here is some info about translating HTTP2 -> HTTP1: |
Hi @joshnuss. I saw that article. I'm not sure too if it is enough. But... to have a fully http2 flow I think that a lote of changes has to be made out of the scope of that particular issue. For example, the article sugest to calculate the method and URL out of pseudo-headers, but the current kit design receives that info on directily of the "req" param. Choosing to do that, we are automaticaly striping info from the original request, wich may be a problem on non http2 scenarios. Actually I kind of did that first, but o felt a bit too much. /** @type {import('@sveltejs/kit/node').GetRequest} */
export async function getRequest(base, req) {
const headers = Object.fromEntries(
Object.entries(/** @type {Record<string, string>} */ (req.headers)).filter(
([key]) => !/^:/.test(key)
)
);
//http2 pseudo-headers, even out off the header, should have priority to determine method, host and url.
const method = /** @type {string} */(req.headers[':method']) || req.method;
//const status = /** @type {string} */(req.headers[':status']) || req.statusCode;
let url = base + req.url;
if (req.headers[':scheme'] && req.headers[':authority'] && req.headers[':path']) {
url = req.headers[':scheme'] + '://' + req.headers[':authority'] + req.headers[':path'];
}
return new Request(url, {
method,
headers,
body: await get_raw_body(req) // TODO stream rather than buffer
});
} |
Just updated to SvelteKit 1.0.0-next.241 then did a |
Just updated to SvelteKit 1.0.0-next.243 and, like @nstuyvesant, am seeing the same "Invalid request body" exception. This is a hard blocker for us as https development is required for our application(s). Is there any guidance/workaround at this time? At this point we are frozen at:
Thank you. |
I've opened #3553 to hopefully address this. If people could take a look at that and confirm whether that fixes their issue, that would be appreciated. |
In the meantime, or if you don't want to try using a local version of SvelteKit, you should be able to work around this by setting |
@Conduitry: Thank you. Setting kit.vite.server.proxy = {} in our svelte.config.js has allowed us to upgrade to:
|
Describe the bug
Running
pnpm run dev -- --https
should serve the project athttps://localhost:3000
.Reproduction
pnpm init svelte@next https-bug && cd https-bug && pnpm install
https
enabled:pnpm run dev -- --https
https://localhost:3000
Logs
System Info
Severity
blocking all usage of SvelteKit for apps that require ssl.
Additional Information
No response
The text was updated successfully, but these errors were encountered: