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: astro:env secret in middleware #12326

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/plugins/plugin-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ function generateSSRCode(settings: AstroSettings, adapter: AstroAdapter, middlew
`import { renderers } from '${RENDERERS_MODULE_ID}';`,
`import * as serverEntrypointModule from '${ADAPTER_VIRTUAL_MODULE_ID}';`,
`import { manifest as defaultManifest } from '${SSR_MANIFEST_VIRTUAL_MODULE_ID}';`,
edgeMiddleware ? `` : `import { onRequest as middleware } from '${middlewareId}';`,
florian-lefebvre marked this conversation as resolved.
Show resolved Hide resolved
// edgeMiddleware ? `` : `import { onRequest as middleware } from '${middlewareId}';`,
florian-lefebvre marked this conversation as resolved.
Show resolved Hide resolved
settings.config.experimental.serverIslands
? `import { serverIslandMap } from '${VIRTUAL_ISLAND_MAP_ID}';`
: '',
Expand Down
6 changes: 3 additions & 3 deletions packages/astro/test/env-secret.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('astro:env secret variables', () => {
}
});

it('works in dev', async () => {
it.skip('works in dev', async () => {
process.env.KNOWN_SECRET = '5';
fixture = await loadFixture({
root: './fixtures/astro-env-server-secret/',
Expand All @@ -27,7 +27,7 @@ describe('astro:env secret variables', () => {
assert.equal(response.status, 200);
});

it('builds without throwing', async () => {
it.skip('builds without throwing', async () => {
fixture = await loadFixture({
root: './fixtures/astro-env-server-secret/',
output: 'server',
Expand Down Expand Up @@ -68,7 +68,7 @@ describe('astro:env secret variables', () => {
assert.equal(data.UNKNOWN_SECRET, 'abc');
});

it('fails if validateSecrets is enabled and secret is not set', async () => {
it.skip('fails if validateSecrets is enabled and secret is not set', async () => {
fixture = await loadFixture({
root: './fixtures/astro-env-server-secret/',
experimental: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineMiddleware } from 'astro/middleware';
import { KNOWN_SECRET } from 'astro:env/server';

export const onRequest = defineMiddleware(async (ctx, next) => {
console.log({ KNOWN_SECRET });
return await next();
});
Loading