Open vinibiavatti1 opened 2 years ago
related: #5194
Hi @sapphi-red, could you help with this issue (and the related one)? Maybe it's in some file where the file path gets resolved, some util function that needs to take into account %20
?
This issue is still active. Had a project with %20 in the title and the vite dev did not work with 404 returned.
Issue is still active as of 1st of August
Issue still active as of 23rd of August 2033. Was a bit frustrating but thanks for the solution in the meantime!
Still active, It took some time but this solve it for me, thanks!
Same here also with Umlauts: ä,ö etc. Huge problem for me, since i rely on it testing german data
Still active in September 2023...
Still happening Jan 2024. Glad this article was here after I cloned a repo from Azure that allows poorly name git projects.
Hello,
Met the same problem today, a friend told me to comment my root property in vite.config.ts :
import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react';
export default defineConfig({ base: '/', plugins: [react()], // root: './src', (vite seems to do not find my files inside ./src) });
Hope that could help
Is there any fix for this? I think i will return back to CRA :/
Hello! Any update about this issue?
when I add that like into my vercel.json
file then everything works perfectly 🐸
{
"rewrites": [
{
"source": "/(.*)",
"destination": "/"
}
]
}
@geolffreym @ozanmanav @steckdev @tripolskypetr
@devlopersabbir Thank you alot. Adding vercel.json for my vercel deployment worked well. 👍🏿
Describe the bug
Hello. I'm here to report a bug that I found using Vite.
History
I had cloned a personal project that was configured to use Vite for build and serve the solution. After cloned this project, I ran the
vite dev
to start the application, but after enter inhttp://localhost:3000
, it returned 404 error. When I tried to find other resources that was present in the/public
folder, likehttp://localhost:3000/favicon.ico
it returned successfully.After doing some tests to discover the reason for the 404 status by accessing the
index.html
file, I could not find the solution. The project that I was using with vite was created fromnpx create-react-app --template typescript
boilerplate, and the configuration of the Vite was made by hand. Acording with this, I decided to create a react app by using the Vite CLI, and this project started perfectly. So, by tranfering the resources from the first project to the other one, and testing the result little by little, I got both projects completly equal, with the same configurations, plugins, and dependencies. But, the first one still didn't work, but the second (test project) was working normally.So, the unique difference of the project was the name of them, one was "My%20Project", and the second one was "test". So, after decided to change the name of the first one removing the charcode
%20
, the project started working. After putting back the charcode, and ran thevite dev
command, the 404 status code was returned again.Tests
I created some projects using vite, and for any project, when the root folder has the
%20
charcode in the name, the 404 HTTP status is shown.I used the
react-scripts
for build and serve the solution, and it worked as well.Steps
npm create vite@latest
vanilla
for the frameworkvanilla
for the variantvite-project
tovite%20project
npm install
to install the dependenciesnpm run dev
to run the apphttp://localhost:3000/
Stack Overflow Top: https://stackoverflow.com/questions/72834388/vite-with-create-react-app-is-returning-404-error/72848313#72848313
Reproduction
Cannot reproduce via vite.new
System Info
Used Package Manager
npm
Logs
Click to expand!
```shell PS C:\Users\USER\Desktop\Vite Tests\vite%20project> npm run dev npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead. > vite-project@0.0.0 dev > vite --debug vite:config no config file found. +0ms vite:config using resolved config: { vite:config root: 'C:/Users/USER/Desktop/Vite Tests/vite%20project', vite:config base: '/', vite:config mode: 'development', vite:config configFile: undefined, vite:config logLevel: undefined, vite:config clearScreen: undefined, vite:config server: { vite:config preTransformRequests: true, vite:config fs: { strict: true, allow: [Array], deny: [Array] } vite:config }, vite:config configFileDependencies: [], vite:config inlineConfig: { vite:config root: undefined, vite:config base: undefined, vite:config mode: undefined, vite:config configFile: undefined, vite:config logLevel: undefined, vite:config clearScreen: undefined, vite:config server: {} vite:config }, vite:config resolve: { dedupe: undefined, alias: [ [Object], [Object] ] }, vite:config publicDir: 'C:\\Users\\USER\\Desktop\\Vite Tests\\vite%20project\\public', vite:config cacheDir: 'C:\\Users\\USER\\Desktop\\Vite Tests\\vite%20project\\node_modules\\.vite', vite:config command: 'serve', vite:config isWorker: false, vite:config isProduction: false, vite:config plugins: [ vite:config 'vite:pre-alias', vite:config 'alias', vite:config 'vite:modulepreload-polyfill', vite:config 'vite:resolve', vite:config 'vite:optimized-deps', vite:config 'vite:html-inline-proxy', vite:config 'vite:css', vite:config 'vite:esbuild', vite:config 'vite:json', vite:config 'vite:wasm', vite:config 'vite:worker', vite:config 'vite:asset', vite:config 'vite:define', vite:config 'vite:css-post', vite:config 'vite:worker-import-meta-url', vite:config 'vite:client-inject', vite:config 'vite:import-analysis' vite:config ], vite:config build: { vite:config target: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ], vite:config polyfillModulePreload: true, vite:config outDir: 'dist', vite:config assetsDir: 'assets', vite:config assetsInlineLimit: 4096, vite:config cssCodeSplit: true, vite:config cssTarget: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ], vite:config sourcemap: false, vite:config rollupOptions: {}, vite:config minify: 'esbuild', vite:config terserOptions: {}, vite:config write: true, vite:config emptyOutDir: null, vite:config manifest: false, vite:config lib: false, vite:config ssr: false, vite:config ssrManifest: false, vite:config reportCompressedSize: true, vite:config chunkSizeWarningLimit: 500, vite:config watch: null, vite:config commonjsOptions: { include: [Array], extensions: [Array] }, vite:config dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] } vite:config }, vite:config preview: { vite:config port: undefined, vite:config strictPort: undefined, vite:config host: undefined, vite:config https: undefined, vite:config open: undefined, vite:config proxy: undefined, vite:config cors: undefined, vite:config headers: undefined vite:config }, vite:config env: { BASE_URL: '/', MODE: 'development', DEV: true, PROD: false }, vite:config assetsInclude: [Function: assetsInclude], vite:config logger: { vite:config hasWarned: false, vite:config info: [Function: info], vite:config warn: [Function: warn], vite:config warnOnce: [Function: warnOnce], vite:config error: [Function: error], vite:config clearScreen: [Function: clearScreen], vite:config hasErrorLogged: [Function: hasErrorLogged] vite:config }, vite:config packageCache: Map(0) {}, vite:config createResolver: [Function: createResolver], vite:config optimizeDeps: { vite:config esbuildOptions: { keepNames: undefined, preserveSymlinks: undefined } vite:config }, vite:config worker: { vite:config format: 'iife', vite:config plugins: [ vite:config [Object], [Object], vite:config [Object], [Object], vite:config [Object], [Object], vite:config [Object], [Object], vite:config [Object], [Object], vite:config [Object], [Object], vite:config [Object], [Object], vite:config [Object], [Object], vite:config [Object] vite:config ], vite:config rollupOptions: {} vite:config } vite:config } +12ms vite v2.9.13 dev server running at: > Local: http://localhost:3000/ > Network: use `--host` to expose ready in 149ms. vite:deps scanning for dependencies... { timestamp: true } +0ms vite:deps Crawling dependencies using entries: vite:deps C:/Users/USER/Desktop/Vite Tests/vite%20project/index.html +0ms vite:resolve 0.93ms /main.js -> C:/Users/USER/Desktop/Vite Tests/vite%20project/main.js +0ms vite:deps Scan completed in 39.91ms: {} +29ms vite:deps dependencies found: { timestamp: true } +41ms vite:deps ✨ optimized dependencies unchanged { timestamp: true } +4ms vite:spa-fallback Rewriting GET / to /index.html +0ms vite:time 3.77ms /index.html +0ms ```Validations