-
-
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
dev/preview paths #2189
dev/preview paths #2189
Conversation
🦋 Changeset detectedLatest commit: 311303c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This is mostly done, but we're sort of blocked by vitejs/vite#2009 — because the asset path used by |
Also, need to update the docs |
One thing I missed somehow is that we're still not actually serving the app on the basepath during dev and preview. Working on that |
Ok, this is basically done apart from docs, I think. I don't think vitejs/vite#2009 should block us, since it's not a regression — it just means that if you're using |
will do docs after lunch |
packages/kit/src/core/dev/index.js
Outdated
handle: hooks.handle || (({ request, resolve }) => resolve(request)), | ||
serverFetch: hooks.serverFetch || fetch | ||
const rendered = | ||
parsed.pathname.startsWith(config.kit.paths.base) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if you could create a variable for parsed.pathname.startsWith(config.kit.paths.base)
to avoid prettier indenting all the subsequent lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it won't make any difference, it could be x &&
and prettier would still put them on separate lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. You could change it like this to avoid the extra indentation:
if (!parsed.pathname.startsWith(config.kit.paths.base)) {
res.statusCode = 404;
res.end('Not found');
return;
}
const rendered = await respond(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could, i just don't love the duplication of
res.statusCode = 404;
res.end('Not found');
maybe it's the lesser of two evils. not sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could refactor that out:
function not_found(res) {
res.statusCode = 404;
res.end('Not found');
}
if (!parsed.pathname.startsWith(config.kit.paths.base)) {
return not_found(res);
}
Nice! This looks like it cleans some stuff up a bit |
following up #2145 (comment)
Before submitting the PR, please make sure you do the following
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpx changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0