Skip to content

APIRoute vs public files follow different precedence in dev and build #15165

@3x10RaiseTo8

Description

@3x10RaiseTo8

Astro Info

Astro                    v5.16.6
Vite                     v6.4.1
Node                     v22.18.0
System                   Windows (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/sitemap (v3.6.0)

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

all

Describe the Bug

If filename of a file in public/ dir is same as filename produced by APIRoute in root,

Example

public/robots.txt exists
src/pages/robots.txt.ts exists

Difference in behaviour:

  1. astro dev: public route takes precedence
  2. astro build: pages route takes precedence

Normal behaviour if no conflicting routes (i.e., only one of those files exists)

What's the expected result?

Not documented as per my knowledge: https://docs.astro.build/en/guides/routing/#route-priority-order

Link to Minimal Reproducible Example

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

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)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions