Nginx history mode settings when PWA in a subfolder?



  • Hi, I have enabled history mode, and it works perfectly in my dev environment, but when I try to upload my build to the server, I get nothing but 404 errors. I am pretty sure the problem is that my app does not live at the top level of this server, but in a subdirectory. (So instead of my site being at https://my.site.net/ it is at https://my.site.net/subfolder/). I have tried adding following to the nginx config, and they all fail in exactly the same way (a bunch of 404 errors):

    location  /subfolder {
       try_files $uri $uri/ /subfolder/index.html;
    }
    
    location  ^~ /subfolder {
       try_files $uri $uri/ /index.html;
    }
    
    location  ^~ /subfolder {
       try_files $uri $uri/ /subfolder/index.html;
    }
    

    Does anyone know how to properly configure this for an app that lives in a subfolder? Thanks!



  • @ssuess try rewrite, with all the base folders you’re using in your quasar app. The trick is, it should be visible from client and accessible from server:

    http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite



  • I finally gave up trying to make this work in a subfolder. I made a new subdomain and served it as the top level. Now the location redirects work as expected.


Log in to reply