diff --git a/.changeset/little-tables-decide.md b/.changeset/little-tables-decide.md new file mode 100644 index 000000000000..4389ec468342 --- /dev/null +++ b/.changeset/little-tables-decide.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/adapter-node': patch +--- + +[fix] only add handlers for directories that exist diff --git a/.changeset/pre.json b/.changeset/pre.json index 8f83bc85edb5..ceed07a54364 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -254,6 +254,7 @@ "light-roses-teach", "little-boats-allow", "little-shirts-happen", + "little-tables-decide", "long-bulldogs-invent", "long-hotels-hunt", "long-moles-fold", @@ -371,6 +372,7 @@ "quiet-mangos-shop", "quiet-mugs-matter", "quiet-singers-fly", + "quiet-terms-fail", "quiet-waves-compete", "rare-mice-mate", "rare-pots-invite", diff --git a/packages/adapter-auto/CHANGELOG.md b/packages/adapter-auto/CHANGELOG.md index cd0fccffe3b8..6a7b2bcd6d03 100644 --- a/packages/adapter-auto/CHANGELOG.md +++ b/packages/adapter-auto/CHANGELOG.md @@ -1,5 +1,12 @@ # @sveltejs/adapter-auto +## 1.0.0-next.7 + +### Patch Changes + +- Updated dependencies [[`a1c02e15`](https://github.com/sveltejs/kit/commit/a1c02e158ae324953c1588aefeae35eee23280bf)]: + - @sveltejs/adapter-vercel@1.0.0-next.34 + ## 1.0.0-next.6 ### Patch Changes diff --git a/packages/adapter-auto/package.json b/packages/adapter-auto/package.json index 84119c2caba2..0ab89d01b2cf 100644 --- a/packages/adapter-auto/package.json +++ b/packages/adapter-auto/package.json @@ -1,6 +1,6 @@ { "name": "@sveltejs/adapter-auto", - "version": "1.0.0-next.6", + "version": "1.0.0-next.7", "repository": { "type": "git", "url": "https://github.com/sveltejs/kit", diff --git a/packages/adapter-node/CHANGELOG.md b/packages/adapter-node/CHANGELOG.md index 8084d09446f9..c9579a5ecd9c 100644 --- a/packages/adapter-node/CHANGELOG.md +++ b/packages/adapter-node/CHANGELOG.md @@ -1,5 +1,11 @@ # @sveltejs/adapter-node +## 1.0.0-next.58 + +### Patch Changes + +- [fix] only add handlers for directories that exist ([#3148](https://github.com/sveltejs/kit/pull/3148)) + ## 1.0.0-next.57 ### Patch Changes diff --git a/packages/adapter-node/package.json b/packages/adapter-node/package.json index cf370cedf44a..4c97ff0dd1b4 100644 --- a/packages/adapter-node/package.json +++ b/packages/adapter-node/package.json @@ -1,6 +1,6 @@ { "name": "@sveltejs/adapter-node", - "version": "1.0.0-next.57", + "version": "1.0.0-next.58", "repository": { "type": "git", "url": "https://github.com/sveltejs/kit", diff --git a/packages/adapter-node/src/handler.js b/packages/adapter-node/src/handler.js index 1bfeecb2b3af..ca766e68ca9c 100644 --- a/packages/adapter-node/src/handler.js +++ b/packages/adapter-node/src/handler.js @@ -1,3 +1,4 @@ +import fs from 'fs'; import path from 'path'; import sirv from 'sirv'; import { fileURLToPath } from 'url'; @@ -14,28 +15,22 @@ const app = new App(manifest); const __dirname = path.dirname(fileURLToPath(import.meta.url)); -const serve_client = sirv(path.join(__dirname, '/client'), { - etag: true, - maxAge: 31536000, - immutable: true, - gzip: true, - brotli: true -}); - -const serve_static = sirv(path.join(__dirname, '/static'), { - etag: true, - maxAge: 31536000, - immutable: true, - gzip: true, - brotli: true -}); - -const serve_prerendered = sirv(path.join(__dirname, '/prerendered'), { - etag: true, - maxAge: 0, - gzip: true, - brotli: true -}); +/** + * @param {string} path + * @param {number} max_age + */ +function serve(path, max_age) { + return ( + fs.existsSync(path) && + sirv(path, { + etag: true, + maxAge: max_age, + immutable: true, + gzip: true, + brotli: true + }) + ); +} /** @type {import('polka').Middleware} */ const ssr = async (req, res) => { @@ -83,4 +78,11 @@ function sequence(handlers) { }; } -export const handler = sequence([serve_client, serve_static, serve_prerendered, ssr]); +export const handler = sequence( + [ + serve(path.join(__dirname, '/client'), 31536000), + serve(path.join(__dirname, '/static'), 31536000), + serve(path.join(__dirname, '/prerendered'), 0), + ssr + ].filter(Boolean) +); diff --git a/packages/adapter-vercel/CHANGELOG.md b/packages/adapter-vercel/CHANGELOG.md index b9592a899d9e..21f96c174f52 100644 --- a/packages/adapter-vercel/CHANGELOG.md +++ b/packages/adapter-vercel/CHANGELOG.md @@ -1,5 +1,11 @@ # @sveltejs/adapter-vercel +## 1.0.0-next.34 + +### Patch Changes + +- Revert to v1 filesystem API ([#3149](https://github.com/sveltejs/kit/pull/3149)) + ## 1.0.0-next.33 ### Patch Changes diff --git a/packages/adapter-vercel/package.json b/packages/adapter-vercel/package.json index 6645b29a7d94..1f68f4ef2c32 100644 --- a/packages/adapter-vercel/package.json +++ b/packages/adapter-vercel/package.json @@ -1,6 +1,6 @@ { "name": "@sveltejs/adapter-vercel", - "version": "1.0.0-next.33", + "version": "1.0.0-next.34", "repository": { "type": "git", "url": "https://github.com/sveltejs/kit",