Skip to content

Path mismatch error when returning HTML file path in static file endpoint that uses dynamic routing #15893

@noahmulfinger

Description

@noahmulfinger

Astro Info

Astro                    v6.0.4
Node                     v22.22.0
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             none

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

No response

Describe the Bug

When I return an HTML file from a static file endpoint that makes use of getStaticPaths to do dynamic routing, the .html ending is removed, causing a path mismatch and resulting in a NoMatchingStaticPathFound error. For example, if I have a path file.html returned as the param value in one of the getStaticPaths entries, I get the below error. If I change the param value to just file, the build succeeds but I end up with a file called file in the output that has no extension.

generating static routes 
17:20:08   ├─ /index.html (+6ms) 
17:20:08   ├─ /file.html17:20:08 [ERROR] NoMatchingStaticPathFound: A `getStaticPaths()` route pattern was matched, but no matching static path was found for requested path `/file`.
    at AstroError (file:///home/projects/github-dnjnvdtp/dist/.prerender/chunks/prerender_BZ2JtAqQ.mjs:77:5)
    at getProps (file:///home/projects/github-dnjnvdtp/dist/.prerender/chunks/prerender_BZ2JtAqQ.mjs:6844:11)
17:20:08 [ERROR] [build] Caught error rendering /file.html: NoMatchingStaticPathFound: A `getStaticPaths()` route pattern was matched, but no matching static path was found for requested path `/file`.
[NoMatchingStaticPathFound] A `getStaticPaths()` route pattern was matched, but no matching static path was found for requested path `/file`.
  Hint:
    Possible dynamic routes being matched: src/pages/[...path].ts.
  Error reference:
    https://docs.astro.build/en/reference/errors/no-matching-static-path-found/
  Stack trace:
    at AstroError (file:///home/projects/github-dnjnvdtp/dist/.prerender/chunks/prerender_BZ2JtAqQ.mjs:77:5)

What's the expected result?

I would expect using a param value like file.html from a static file endpoint to result in a successful build with a file called file.html in the output. This was the case in Astro v5. I've created both a v5 and v6 StackBlitz for comparison:

Link to Minimal Reproducible Example

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

Participation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions