diff options
author | 2023-05-12 10:01:05 -0400 | |
---|---|---|
committer | 2023-05-12 10:01:05 -0400 | |
commit | da9f986d7c6e3659a392f89e39ecd724c394ef53 (patch) | |
tree | c9bb0979f139a7d90abfd0dfe89a79872e70de3d /packages/integrations/node/src | |
parent | 9f38e0b3730c049f7ef6ce8802e6b81c9c405c87 (diff) | |
download | astro-da9f986d7c6e3659a392f89e39ecd724c394ef53.tar.gz astro-da9f986d7c6e3659a392f89e39ecd724c394ef53.tar.zst astro-da9f986d7c6e3659a392f89e39ecd724c394ef53.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; }); |