Skip to content

trailingSlash breaks static output #16185

@tyler71

Description

@tyler71

Astro Info

Astro                    v6.1.3
Vite                     v7.3.1
Node                     v22.13.0
System                   Linux (x64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Astro >6 breaks static output with trailing slash.
Issue does not occur in serve, only when building.

$ cat src/pages/demo.ts
import type { APIRoute } from "astro";

export const GET: APIRoute = async () => {
    const response = new Response("hello");
    response.headers.set("Content-Type", "text/plain");
    return response;
};

Disabled:

export default defineConfig({
//  trailingSlash: "always",
});
$ cat dist/demo
hello

Enabled:

export default defineConfig({
  trailingSlash: "always",
});
$ cat dist/demo
<!doctype html><title>Redirecting to: /demo/</title><meta http-equiv="refresh" content="0;url=/demo/"><meta name="robots" content="noindex"><link rel="canonical" href="/demo/"><body>	<a href="/demo/">Redirecting from <code>/demo</code> to <code>/demo/</code></a></body>%

What's the expected result?

demo should render with its output of "hello" instead of redirecting to a non-existent page.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-dghg4t8k

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

Labels

- P4: importantViolate documented behavior or significantly impacts performance (priority)pkg: astroRelated to the core `astro` package (scope)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions