I'm working on a React project using Vite. My JSON files are placed in public/data/2025
. Most of them, such as muenster.json
, load just fine via http://localhost:5173/data/2025/muenster.json. However, every newly added file, e.g. cologne.json
, keeps failing. Vite just serves index.html
for those files.
I have verified that:
The file paths are correct (
public/data/2025/cologne.json
).The JSON file is valid JSON (checked with JSON validators).
The file permissions are the same as
muenster.json
.I've tried removing any possible BOM (Byte Order Mark) or hidden characters using hexdump and xattr on macOS.
I restarted the dev server multiple times (
npm run dev
).I tested a minimal file (
{"test":true}
) in the same folder, and that also doesn't load.My
vite.config.js
is very minimal:import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' export default defineConfig({ plugins: [react()], server: { fs: { strict: false } } })
Other JSON files from that folder can be fetched and parsed without issues. Why would one (or more) JSON file(s) in public/data/
not be served properly, while all the others are? Is there something else I need to configure in Vite to ensure every file in the public folder is served without issues?