Skip to content

Commit

Permalink
Add back check to see if path starts with base url
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Sep 22, 2021
1 parent ad99e9e commit 19c170b
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/kit/src/core/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,18 @@ export async function preview({

const parsed = new URL(initial_url, 'http://localhost/');

const rendered = await app.render({
host: /** @type {string} */ (
config.kit.host || req.headers[config.kit.hostHeader || 'host']
),
method: req.method,
headers: /** @type {import('types/helper').RequestHeaders} */ (req.headers),
path: parsed.pathname.replace(config.kit.paths.base, ''),
query: parsed.searchParams,
rawBody: body
});
const rendered =
parsed.pathname.startsWith(config.kit.paths.base) &&
(await app.render({
host: /** @type {string} */ (
config.kit.host || req.headers[config.kit.hostHeader || 'host']
),
method: req.method,
headers: /** @type {import('types/helper').RequestHeaders} */ (req.headers),
path: parsed.pathname.replace(config.kit.paths.base, ''),
query: parsed.searchParams,
rawBody: body
}));

if (rendered) {
res.writeHead(rendered.status, rendered.headers);
Expand Down

0 comments on commit 19c170b

Please sign in to comment.