Unable to Render the App in the Server , Shows blank screen .
Hi ,
I am using create-react-app for my react app . So after building the final application by running the npm run build , i came to know that if it is deployed in the server we need to mention the server path in the package.json under "homepage" .
But the thing is , there are two applications running on the server one under the /var/www/html and another under /var/www/html/myapp/ . so if we access the URL like mywebpage.com -> it by default picks the index.html under /var/www/html .
Now i want my react app to run under /var/www/html/myapp . so to achieve this i added the below code in my package.json
"homepage" : "mysite.com/myapp" .
when accessing the URL in the browser , it renders an empty screen . There is no error in the console too.
But the app works in my local , when accessing via localhost in the browser .
I experienced something similar where the blank page is rendering. It means React is not rendering in the <div> with the root id. so all you see is the index.html page and there isn't any error because the index.html empty page is valid.
It sounds like the issue you are experiencing is actually with the web server configuration. The web server would need to be configured to have more than one web destination. Something similar to this: https://opensource.com/article/18/3/configuring-multiple-web-sites-apache depending on your web server.
Make sure you've properly specified a homepage, starting with http://.
If there's no console errors, do there happen to be network ones? Is the index.html being served with the correct path(s) to other resources?
Let us know if you resolved this, thanks!
i did that.. and no luck
Having this same issue most times I deploy new code, too.
I suspect it has to do with the service worker because:
- It's happening across multiple browsers in our staging AND production environments
- Clearing browser cache always fixes the issue
- We are also seeing it locally -- we use a URL in our hosts files to develop locally, not localhost or IP, so service worker DOES deploy
- Seeing it locally eliminates possibility this is nginx (which we're using in staging and production) or express (which we're using locally) since we're seeing it in both places.