fix: allow HTTP to local instances in release build; fix activity 404 in dev
Android release builds block cleartext HTTP by default (debug builds override this via the debug manifest overlay). Add usesCleartextTraffic=true to app.json so expo prebuild includes it in the generated manifest — required to reach local Bincio instances over HTTP. In bincio dev (Astro dev server), /activity/<id>/ routes 404 because getStaticPaths() returns [] and there is no nginx try_files fallback. Add a Vite middleware plugin to astro.config.mjs that rewrites /activity/<id>/ to /activity/ in dev, matching what nginx does in production.
This commit is contained in:
@@ -9,6 +9,20 @@ const env = loadEnv(process.env.NODE_ENV ?? 'development', process.cwd(), '');
|
||||
const apiPort = process.env.VITE_API_PORT || '4041';
|
||||
const serveTarget = env.PUBLIC_EDIT_URL || `http://localhost:${apiPort}`;
|
||||
|
||||
// In production, nginx serves activity/index.html for all /activity/<id>/ URLs
|
||||
// via try_files. In dev (Astro dev server), no nginx — this plugin replicates it.
|
||||
const activityFallbackPlugin = {
|
||||
name: 'activity-shell-fallback',
|
||||
configureServer(server) {
|
||||
server.middlewares.use((req, _res, next) => {
|
||||
if (req.url && /^\/activity\/[^/]+\/?(\?|$)/.test(req.url)) {
|
||||
req.url = '/activity/';
|
||||
}
|
||||
next();
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default defineConfig({
|
||||
integrations: [svelte(), tailwind()],
|
||||
devToolbar: { enabled: false },
|
||||
@@ -16,6 +30,7 @@ export default defineConfig({
|
||||
// When hosting at a subdirectory (e.g. GitHub Pages project site), set:
|
||||
// base: "/repo-name",
|
||||
vite: {
|
||||
plugins: [activityFallbackPlugin],
|
||||
optimizeDeps: {
|
||||
include: ['maplibre-gl'],
|
||||
esbuildOptions: { target: 'es2022' },
|
||||
|
||||
Reference in New Issue
Block a user