After deployment my app works for a while then shows blank pages. Nothing works and I have to keep deploying, there are no errors in build nor in console.
Things I have already tried:
- Changed the command to
npm run build
- Tried serving the dist folder locally (works fine)
- No meaningful error in the browser console.
- Build and dev both works fine locally and on Bolt.new
- There are no errors in the deployement.
Link:https://resonant-nougat-8bbd31.netlify.app/
project id: resonant-nougat-8bbd31
@Raoasim Check and adjust your Build Configuration.
You mention that “serving the dist folder locally (works fine)”.
But I suspect you’re just “deploying the root of your project on Netlify”.
Set your Build command to whatever your project requires.
If it’s put together in a way where npm run build
works, then great.
Set your Publish directory to dist
, since it’s what you indicate it should be.
The errors in the browser console are meaningful.
Inspecting why they’re occurring reveals that ‘source code’ has been deployed:
Your project will only work correctly anywhere where you:
- have the right environment
- run the right command
- serve the right output
If you fix the configuration, it’ll work fine on Netlify too.
The fact that it works for a while and then doesn’t , makes me think, I am not doing anything wrong
@Raoasim Perhaps, perhaps not, it certainly doesn’t negate what I’ve outlined, the site cannot load from source code.
What is your Build configuration currently set to?
It’d also help to know what you’re actually working with.
Is it a ‘static site’ or is it something running a ‘server’ or using ‘ssr’?
If it’s static it should be precisely as I’ve outlined, if it’s running a server/ssr then it’s entirely possible that it could respond “one way one time” then “another way the next time”.
And its a vite based react app, so no ssr
@Raoasim That screenshot shows that you haven’t set the Publish directory.
Try changing it to dist
as previously instructed, then trigger a new deployment.
Already tried that, it works but after some redirections, my pages starts giving 404
Only when I again goto homepage and get back on the page, it works.