create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

Unable to Render the App in the Server , Shows blank screen .

Open shyam2794 opened this issue 8 years ago • 4 comments

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 .

shyam2794 avatar Jun 12 '18 19:06 shyam2794

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.

kenwithee avatar Jun 13 '18 01:06 kenwithee

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!

Timer avatar Jun 14 '18 05:06 Timer

i did that.. and no luck

ifeora-emeka avatar Aug 29 '18 03:08 ifeora-emeka

Having this same issue most times I deploy new code, too.

I suspect it has to do with the service worker because:

  1. It's happening across multiple browsers in our staging AND production environments
  2. Clearing browser cache always fixes the issue
  3. 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
  4. 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.

toddalbert avatar Dec 07 '18 13:12 toddalbert