I made a very basic corporate website with create-react-app and used react-router v6 for routing. Everything works fine locally. Then I create a build folder by running following command:
npm run build
I uploaded the contents of build folder and uploaded to the server folder like: /var/www/mysite
On server I am running apache, I create apache site there and pointed root directory to be /var/www/mysite. Now when I try to run the website on my domain like:
www.mysite.com it does not work and shows blank page.
But when I upload the same build into sub folder like /var/www/mysite/v2 and then try to run www.mysite.com/v2 the site works perfectly fine.
I don't know what is wrong. I tried following in package.json file
"homepage": "."
OR
"homepage": "/"
OR
"homepage": "./"
OR
"homepage": "wwww.mysite.com/"
Here are the contents of my .htaccess file that is placed in public directory of project, it gets copied to build folder when build folder is generated:
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
Please tell me what I am doing wrong. I have spent full day trying to figure out what is wrong. This issue is not mentioned in documentation or anywhere online. I have tried all possible fixes available on similar questions but nothing works.
Note: I am not including https in above question wherever www is written because SO does not let me submit question with https.