Skip to content

Dynamic route with empty slug not accessible in dev server when using [path]/[slug]/[page].astro instead of rest parameter #14699

@ishaanparlikar

Description

@ishaanparlikar

Astro Info

Astro : v5.15.1
Vite: v6.4.1
Node: v20.11.0
System: Windows(x64)
package Manager: pnpm
Output: Static
Adapter: None
Integrations: @astrojs/tailwind (v6.0.2)

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

No response

Describe the Bug

In our project, we’re using a route structure like this:

src/pages/[path]/[slug]/[page].astro

Instead of a rest parameter (e.g. [...params].astro) because our organization uses Perforce, which doesn’t properly handle folders with ... in their names.

However, when the slug parameter is empty, the route fails to load in the dev server — it throws a 404 or doesn’t resolve the page at all.

If we explicitly pass the slug as ".", the project builds and works as expected, but this is obviously not a valid workaround.

Steps to Reproduce

  1. Create a page structure:

    src/pages/[path]/[slug]/[page].astro
    
  2. Try accessing a route where slug is empty (e.g. /blog//page-name).

  3. Observe that it fails in dev but works in the build if slug is ".".

[200] /path/slug/test 4ms
[404] /path//test 1ms

Environment

  • Perforce integration: Yes (rest parameter [...params] not usable due to Perforce folder restrictions)

Additional Context

We’re avoiding rest parameters ([...params].astro) because Perforce does not detect or sync such folders correctly.
Any workaround would be appreciated. We are using it in production and need to cover this usecase.

Thanks


What's the expected result?

  • The route should handle empty or missing slug values gracefully in the dev server, just like it does when building the project.
  • The behaviour between dev and build should be consistent.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-uufp7iri?file=src%2Fpages%2F%5Bpath%5D%2F%5Bslug%5D%2F%5Bpage%5D.astro

Participation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions