Note: I'm focused on a Web build right now, so this question is focused on solving some very specific to web usage.
I'm building a React Native application where the underlying infrastructure is reliant on cookie auth for normal users. I'm using Expo as the framework. To make the cookie stuff as smooth as possible I run all the relevant services locally, a self-signed cert that the system trusts, and use an nginx reverse proxy to keep the routes matching.
Thus, all requests are made to routes like:
https://portal.company.com
https://api.company.com/billing
and nginx is doing a proxy_pass to http://localhost:5000, http://localhost:5001, and so forth.
I made a previous Vite app that had no issue responding to requests on subpaths with this configuration:
server {
listen 443 ssl;
server_name portal.company.com;
ssl_certificate "cert-path//portal-cert.pem";
ssl_certificate_key "cert-path//portal-private.pem";
ssl_session_cache shared:SSL:1m;
ssl_protocols TLSv1.3;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
proxy_set_header Host $host; # MAGIC
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
location / {
include includes/cors;
proxy_pass https://localhost:5173;
}
}
However, when I reused that for the Expo app, subpaths kept throwing up a "Not found" page with a 404, and it was pretty clear my code wasn't running. It was clearly the classic "running a SPA app" issue where it's only technically responding to requests at the app's root, but I didn't see a clear way of getting the request to the root.