Skip to content

Commit

Permalink
fix(node): avoid infinite redirect when trailingSlash: never
Browse files Browse the repository at this point in the history
  • Loading branch information
msxdan committed Dec 9, 2023
1 parent cd13dd6 commit c71720a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/integrations/node/src/http-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function createServer(
const hasSlash = urlPath.endsWith('/');
switch (trailingSlash) {
case "never":
if (isDirectory && hasSlash) {
if (isDirectory && (urlPath != '/') && hasSlash) {
pathname = urlPath.slice(0, -1) + (urlQuery ? "?" + urlQuery : "");
res.statusCode = 301;
res.setHeader('Location', pathname);
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function createIntegration(userOptions: UserOptions): AstroIntegr
server: config.build.server?.toString(),
host: config.server.host,
port: config.server.port,
trailingSlash: config.trailingSlash
trailingSlash: config.trailingSlash,
assets: config.build.assets,
};
setAdapter(getAdapter(_options));
Expand Down

0 comments on commit c71720a

Please sign in to comment.