From 57d83700da525f9420146963b748b4ede83295e4 Mon Sep 17 00:00:00 2001 From: Tee Ming Date: Wed, 23 Aug 2023 17:02:06 +0800 Subject: [PATCH] fix: account for `config.kit.paths.base` when building with `adapter-cloudflare` (#10604) fixes #10290 Correctly includes the base path config setting when resolving the path to the _app directory. --- .changeset/eighty-cats-wave.md | 5 +++++ packages/adapter-cloudflare/index.js | 4 ++-- packages/kit/src/exports/public.d.ts | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/eighty-cats-wave.md diff --git a/.changeset/eighty-cats-wave.md b/.changeset/eighty-cats-wave.md new file mode 100644 index 000000000000..f708f58ff49d --- /dev/null +++ b/.changeset/eighty-cats-wave.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/adapter-cloudflare': patch +--- + +fix: correctly include `config.kit.paths.base` diff --git a/packages/adapter-cloudflare/index.js b/packages/adapter-cloudflare/index.js index 46e1c2c3800b..1dd0abd06470 100644 --- a/packages/adapter-cloudflare/index.js +++ b/packages/adapter-cloudflare/index.js @@ -36,7 +36,7 @@ export default function (options = {}) { JSON.stringify(get_routes_json(builder, written_files, options.routes ?? {}), null, '\t') ); - writeFileSync(`${dest}/_headers`, generate_headers(builder.config.kit.appDir), { flag: 'a' }); + writeFileSync(`${dest}/_headers`, generate_headers(builder.getAppPath()), { flag: 'a' }); builder.copy(`${files}/worker.js`, `${tmp}/_worker.js`, { replace: { @@ -87,7 +87,7 @@ function get_routes_json(builder, assets, { include = ['/*'], exclude = ['' .flatMap((rule) => (rule === '' ? ['', '', ''] : rule)) .flatMap((rule) => { if (rule === '') { - return `/${builder.config.kit.appDir}/*`; + return `/${builder.getAppPath()}/*`; } if (rule === '') { diff --git a/packages/kit/src/exports/public.d.ts b/packages/kit/src/exports/public.d.ts index 98ee3c9116b0..13169dfb1f5d 100644 --- a/packages/kit/src/exports/public.d.ts +++ b/packages/kit/src/exports/public.d.ts @@ -119,7 +119,7 @@ export interface Builder { getClientDirectory(): string; /** Get the fully resolved path to the directory containing server-side code. */ getServerDirectory(): string; - /** Get the application path including any configured `base` path, e.g. `/my-base-path/_app`. */ + /** Get the application path including any configured `base` path, e.g. `my-base-path/_app`. */ getAppPath(): string; /**