diff options
author | 2023-05-12 10:01:05 -0400 | |
---|---|---|
committer | 2023-05-12 10:01:05 -0400 | |
commit | 781f558c401a5f02927d150e4628a77c55cccd28 (patch) | |
tree | 4871502118fabab0f936ffa7a6b6c0d664c860bf /packages/integrations/node/src | |
parent | 0fc026f63c92766ca69f992ee5ca4d17453860f5 (diff) | |
download | astro-781f558c401a5f02927d150e4628a77c55cccd28.tar.gz astro-781f558c401a5f02927d150e4628a77c55cccd28.tar.zst astro-781f558c401a5f02927d150e4628a77c55cccd28.zip |
Correct handle directory finds when using base in the Node adapter (#7076)
Diffstat (limited to 'packages/integrations/node/src')
-rw-r--r-- | packages/integrations/node/src/http-server.ts | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/packages/integrations/node/src/http-server.ts b/packages/integrations/node/src/http-server.ts index 850d61bbb..2c58c0da7 100644 --- a/packages/integrations/node/src/http-server.ts +++ b/packages/integrations/node/src/http-server.ts @@ -55,7 +55,13 @@ export function createServer( // File not found, forward to the SSR handler handler(req, res); }); - + stream.on('directory', () => { + // On directory find, redirect to the trailing slash + const location = req.url + '/'; + res.statusCode = 301 + res.setHeader('Location', location); + res.end(location); + }); stream.on('file', () => { forwardError = true; }); |