I have a client with react app. The server is using apache, and he configured the app to be on:
http://my-domain.com/frame
I have build the app and it loads (css+js), but some routing issues still remain. For example, I am using routes, so there are pages like:
http://localhost:3000/frame
http://localhost:3000/page1
http://localhost:3000/page2
It works in my local, and on the server routing works when using the app normally, but when refreshing the page, it "loses" the routing and show error. I mean:
http://my-domain.com/frame
http://my-domain.com/page1
http://my-domain.com/page2
works as long as I am in the app (so frame
-> page1
-> page2
works, but going directly to page1
doesn't).
My apache .htacess:
<IfModule mod_rewrite.c>
RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
# If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html
</IfModule>
package.json:
{
...
"homepage": ".",
...
}
public/manifest.json:
{
...
"start_url": ".",
...
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…