SchabanBo / qlevar_router

Manage you project Routes. Create nested routes. Simply navigation without context to your pages. Change only one sub widget in your page when navigating to new route.
MIT License
86 stars 22 forks source link

Error using Nested Routes & setUrlStrategy #114

Closed guilherme-diniz closed 1 year ago

guilherme-diniz commented 1 year ago

If I set the UrlStrategy (using QR.setUrlStrategy) and create a Nested Navigator, when I refresh the page I get a blank screen. If I remove the setUrlStrategy, everything works out.

With setUrlStrategy

Captura de Tela 2023-03-06 às 19 33 59

Without setUrlStrategy

Captura de Tela 2023-03-06 às 19 35 18

SchabanBo commented 1 year ago

Actually, it is a limitation from the browser and not a Problem from the package. See this Here the same thing is happening when you reload the page, without the hashtag, you are requesting the file in the path /home/coffee, which doesn't exist. As you see here, the browser is requesting the /home/main.dart.js image

devhammed commented 1 year ago

@guilherme-diniz The solution is to make all unknown requests go to the index.html file (just like the setup in SPA sites).

Below are sample configurations for Apache & Nginx servers:

Apache:

<VirtualHost *:80>
    ServerName mydomainname.in
    DirectoryIndex index.html
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Location / >
        RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule . /index.html [L]
    </Location>
</VirtualHost>

Nginx:

server {
    server_name mydomainname.in;
    index index.html;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /usr/share/nginx/html;

    location / {
        try_files $uri $uri/ /index.html;
    }
}