@sveltejs/kit 1.2.5 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -364,10 +364,13 @@ export async function dev(vite, vite_config, svelte_config) {
364
364
  /** @type {function} */ (middleware.handle).name === 'viteServeStaticMiddleware'
365
365
  );
366
366
 
367
+ // Vite will give a 403 on URLs like /test, /static, and /package.json preventing us from
368
+ // serving routes with those names. See https://github.com/vitejs/vite/issues/7363
367
369
  remove_static_middlewares(vite.middlewares);
368
370
 
369
371
  vite.middlewares.use(async (req, res) => {
370
372
  // Vite's base middleware strips out the base path. Restore it
373
+ const original_url = req.url;
371
374
  req.url = req.originalUrl;
372
375
  try {
373
376
  const base = `${vite.config.server.https ? 'https' : 'http'}://${
@@ -375,13 +378,14 @@ export async function dev(vite, vite_config, svelte_config) {
375
378
  }`;
376
379
 
377
380
  const decoded = decodeURI(new URL(base + req.url).pathname);
378
- const file = posixify(path.resolve(decoded.slice(1)));
381
+ const file = posixify(path.resolve(decoded.slice(svelte_config.kit.paths.base.length + 1)));
379
382
  const is_file = fs.existsSync(file) && !fs.statSync(file).isDirectory();
380
383
  const allowed =
381
384
  !vite_config.server.fs.strict ||
382
385
  vite_config.server.fs.allow.some((dir) => file.startsWith(dir));
383
386
 
384
387
  if (is_file && allowed) {
388
+ req.url = original_url;
385
389
  // @ts-expect-error
386
390
  serve_static_middleware.handle(req, res);
387
391
  return;