Vercel: 404 NOT_FOUND when refreshing a page in a React Router / single-page app
#125Error
404: NOT_FOUND Code: NOT_FOUND
Why it happens, and why this works
In a single-page app the routes (/about, /dashboard) only exist in the browser. A refresh or direct link asks the server for that path, and there's no file there.
Fix
Send every non-file route to index.html. On Vercel add vercel.json: { "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }] }. On Netlify add public/_redirects with: /* /index.html 200. Next.js projects don't need this.Did it work?
No reports yetRelated fixes
npm publish of a new package fails with 404 Not Found on PUT, then 403 two-factor required
#21npm publish fails: 404 Not Found - PUT https://registry.npmjs.org/<package> - Not found. "could not be found or you do not have permission to access it" (first publish of a new package). After logging in again: 403 Forbidden - Two-factor authentication or granular access token with bypass 2fa enabled is required to publish packages.
Invalid hook call. Hooks can only be called inside of the body of a function component
#151Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons: 1. You might have mismatching versions of React and the renderer (such as React DOM) 2. You might be breaking the Rules of Hooks 3. You might have more than one copy of React in the same app
Vercel: No Output Directory named "dist" found after the Build completed
#124Error: No Output Directory named "dist" found after the Build completed. You can configure the Output Directory in your Project Settings.