-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix(node): Custom headers are not present in responses from standalon…
…e Node server in preview mode (#10208) * fix(node): add user specified headers to preview server responses * docs: clarify comment * style: new line * test: remove test * chore: add changeset
- Loading branch information
Showing
8 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@astrojs/node": patch | ||
"astro": patch | ||
--- | ||
|
||
Fixes custom headers are not added to the Node standalone server responses in preview mode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/integrations/node/test/fixtures/preview-headers/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@test/nodejs-preview-headers", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*", | ||
"@astrojs/node": "workspace:*" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/integrations/node/test/fixtures/preview-headers/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as assert from 'node:assert/strict'; | ||
import { after, before, describe, it } from 'node:test'; | ||
import nodejs from '../dist/index.js'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('Astro preview headers', () => { | ||
/** @type {import('./test-utils').Fixture} */ | ||
let fixture; | ||
let devPreview; | ||
const headers = { | ||
astro: 'test', | ||
}; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/preview-headers/', | ||
output: 'server', | ||
adapter: nodejs({ mode: 'standalone' }), | ||
server: { | ||
headers | ||
}, | ||
}); | ||
await fixture.build(); | ||
devPreview = await fixture.preview(); | ||
}); | ||
|
||
after(async () => { | ||
await devPreview.stop(); | ||
}); | ||
|
||
describe('Preview Headers', () => { | ||
it('returns custom headers for valid URLs', async () => { | ||
const result = await fixture.fetch('/'); | ||
assert.equal(result.status, 200); | ||
assert.equal(Object.fromEntries(result.headers).astro, headers.astro); | ||
}); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.