-
-
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
adapter-node is erroring on all requests #801
Comments
Yikes, yeah I can reproduce this from the starter template. |
kit/packages/adapter-node/src/server.js Line 34 in ca33a35
const parsed = new URL(req.url || '', 'http://localhost'); |
This was broken in #774. The Vercel adapter is constructing the origin from |
My proposed fix is diff --git a/packages/adapter-node/src/server.js b/packages/adapter-node/src/server.js
index f93e6cb..15947db 100644
--- a/packages/adapter-node/src/server.js
+++ b/packages/adapter-node/src/server.js
@@ -31,7 +31,7 @@ const assets_handler = sirv(join(__dirname, '/assets'), {
polka()
.use(compression({ threshold: 0 }), assets_handler, prerendered_handler, async (req, res) => {
- const parsed = new URL(req.url || '');
+ const parsed = new URL(req.url || '', 'http://localhost');
const rendered = await app.render({
method: req.method,
headers: req.headers, // TODO: what about repeated headers, i.e. string[]
diff --git a/packages/adapter-vercel/src/entry.js b/packages/adapter-vercel/src/entry.js
index 38b7cde..5af07aa 100644
--- a/packages/adapter-vercel/src/entry.js
+++ b/packages/adapter-vercel/src/entry.js
@@ -3,8 +3,7 @@ import { URL } from 'url';
import { get_body } from '@sveltejs/kit/http';
export default async (req, res) => {
- const host = `${req.headers['x-forwarded-proto']}://${req.headers.host}`;
- const { pathname, searchParams } = new URL(req.url || '', host);
+ const { pathname, searchParams } = new URL(req.url || '', 'http://localhost');
const { render } = await import('./server/app.mjs');
but I don't know why tests didn't catch this. |
it works on my machine 😅 - I'm wondering why. I did the initial part of #774, tested it with vercel and it was fine.
|
No, the Vercel part is fine - it's just doing more than is needed. (We don't need an accurate base URL to resolve |
This snuck through CI because the adapters don't currently have tests - #639. I'll open a PR with a fix for the Node adapter and the simplification for the Vercel adapter. |
This is fixed in |
Updating adapt-node from
"1.0.0-next.09",
to"1.0.0-next.11"
is now resulting in the error always being raised when running the server.node build/index.js
^ This results in the server crashing and not serving a 404 which is also interesting
I have confirmed that downgrading back to 09 fixes the issue on my end.
The text was updated successfully, but these errors were encountered: