gawati / gawati-portal-ui

Version 2 of the gawati portal
GNU Affero General Public License v3.0
0 stars 0 forks source link

URL results in a 404 on refresh #33

Closed kohsah closed 6 years ago

kohsah commented 6 years ago

visit https://dev.gawati.org

it redirects to https://dev.gawati.org/_lang/en/

if you hit the browser refresh button now on the redirected page, we get a 404 error.

The problem manifested since the change from HashRouter to BrowserRouter

Arunadevi commented 6 years ago

https://dev.gawati.org/static/css/main.db7f4033.css in the first case is changed to https://dev.gawati.org/_lang/en/static/css/main.db7f4033.css in the second

On Tue, Feb 27, 2018 at 5:54 PM, Ashok H notifications@github.com wrote:

visit https://dev.gawati.org

it redirects to https://dev.gawati.org/_lang/en/

if you hit the browser refresh button now on the redirected page, we get a 404 error.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gawati/gawati-portal-ui/issues/33, or mute the thread https://github.com/notifications/unsubscribe-auth/ADnEEIImklHslAzFvmB1wTTpqJL6Hxg_ks5tY_QWgaJpZM4SU2Cd .

kohsah commented 6 years ago

@Arunadevi ok the browserrouter has possibly broken the homepage="." config in package.json ... "#" has a different meaning in the context of urls so setting "." to homepage in that case was not breaking the url boundaries ...

So probably needs to be set to "/" or the specific vdir or the domain it is hosted at ... not sure.

This manifests only with built sites run with npm run build

kohsah commented 6 years ago

This is related to changes in issue #26

kohsah commented 6 years ago

See this comment: https://github.com/gawati/gawati-portal-ui/issues/26#issuecomment-369182793 that basically contains the fix for the 404 ... basically instead of "." for the homepage setting use a specific domain / vdir path

kohsah commented 6 years ago

Here is the correct httpd conf to resolve this issue (Note the use of RewriteCond below which resolves the refresh 404 issue. This isn't there currently. Will update the documentation to reflect the same.

<VirtualHost *:80>
ProxyRequests off
ServerName gawati.local
ServerAlias gawati.local

DocumentRoot "path/to/gawati-portal-ui/build"

<Directory  "path/to/gawati-portal-ui/build">
    DirectoryIndex "index.html"
    Require all granted
    AllowOverride All

    ## the following is required for client side routing to work, 
    ## otherwise results in a 404 on refresh

    RewriteEngine on
    # Don't rewrite files or directories
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    # Rewrite everything else to index.html to allow html5 state links
    RewriteRule ^ index.html [L]
</Directory>

Alias /akn "path/to/pdf/akn"
<Directory "path/to/pdf/akn">   
    DirectoryIndex "index.html"
    Require all granted
    AllowOverride All
</Directory>

<Location ~ "/gwd/(.*)">
  AddType text/cache-manifest .appcache
  ProxyPassMatch  "http://localhost:8080/exist/restxq/gw/$1"
  ProxyPassReverse "http://localhost:8080/exist/restxq/gw/$1"
  ProxyPassReverseCookiePath /exist /
  SetEnv force-proxy-request-1.0 1
  SetEnv proxy-nokeepalive 1
</Location>

<Location ~ "/gwp/(.*)">
  AddType text/cache-manifest .appcache
  ProxyPassMatch  "http://localhost:9001/gwp/$1"
  ProxyPassReverse "http://localhost:9001/gwp/$1"
  SetEnv force-proxy-request-1.0 1
  SetEnv proxy-nokeepalive 1
</Location>

</VirtualHost>