Skip to content

Commit

Permalink
fix: account for config.kit.paths.base when building with `adapter-…
Browse files Browse the repository at this point in the history
…cloudflare` (#10604)

fixes #10290

Correctly includes the base path config setting when resolving the path to the _app directory.
  • Loading branch information
eltigerchino authored Aug 23, 2023
1 parent 66f3295 commit 57d8370
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-cats-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-cloudflare': patch
---

fix: correctly include `config.kit.paths.base`
4 changes: 2 additions & 2 deletions packages/adapter-cloudflare/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -87,7 +87,7 @@ function get_routes_json(builder, assets, { include = ['/*'], exclude = ['<all>'
.flatMap((rule) => (rule === '<all>' ? ['<build>', '<files>', '<prerendered>'] : rule))
.flatMap((rule) => {
if (rule === '<build>') {
return `/${builder.config.kit.appDir}/*`;
return `/${builder.getAppPath()}/*`;
}

if (rule === '<files>') {
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/exports/public.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down

0 comments on commit 57d8370

Please sign in to comment.