Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check origin in static build #12070

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tame-pumpkins-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes an issue where the check origin middleware was incorrectly injected when the build output was `"static"`
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ function createBuildManifest(
onRequest: middleware,
};
},
checkOrigin: settings.config.security?.checkOrigin ?? false,
checkOrigin: (settings.config.security?.checkOrigin && settings.buildOutput === "server") ?? false,
key,
envGetSecretEnabled: false,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/plugins/plugin-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function buildManifest(
assets: staticFiles.map(prefixAssetPath),
i18n: i18nManifest,
buildFormat: settings.config.build.format,
checkOrigin: settings.config.security?.checkOrigin ?? false,
checkOrigin: (settings.config.security?.checkOrigin && settings.buildOutput === "server") ?? false,
serverIslandNameMap: Array.from(settings.serverIslandNameMap),
key: encodedKey,
envGetSecretEnabled:
Expand Down
3 changes: 2 additions & 1 deletion packages/astro/src/vite-plugin-astro-server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default function createVitePluginAstroServer({
await createRouteManifest({ settings, fsMod }, logger), // TODO: Handle partial updates to the manifest
);
warnMissingAdapter(logger, settings);
pipeline.manifest.checkOrigin = settings.config.security.checkOrigin && settings.buildOutput === "server";
pipeline.setManifestData(routeManifest);
}
}
Expand Down Expand Up @@ -160,7 +161,7 @@ export function createDevelopmentManifest(settings: AstroSettings): SSRManifest
componentMetadata: new Map(),
inlinedScripts: new Map(),
i18n: i18nManifest,
checkOrigin: settings.config.security?.checkOrigin ?? false,
checkOrigin: (settings.config.security?.checkOrigin && settings.buildOutput === "server") ?? false,
ematipico marked this conversation as resolved.
Show resolved Hide resolved
envGetSecretEnabled: false,
key: createKey(),
middleware() {
Expand Down
Loading