fix(mobile): move baseUrl config to experiments.baseUrl and filter static assets in express wildcard handler

This commit is contained in:
Plena Finance Dev
2026-07-09 11:55:31 +05:30
parent 9c7c576c99
commit 65fdc108a8
2 changed files with 11 additions and 3 deletions

View File

@@ -49,6 +49,14 @@ app.get('/{*path}', (req, res, next) => {
if (req.path.startsWith(apiRoot)) return next(); if (req.path.startsWith(apiRoot)) return next();
if (req.path === '/_cron/tick') return next(); if (req.path === '/_cron/tick') return next();
// Do not serve HTML for static assets or requests that do not accept HTML
const isAsset = /\.[a-z0-9]{2,4}$/i.test(req.path);
const acceptsHtml = req.headers.accept?.includes('text/html');
if (isAsset || !acceptsHtml) {
res.status(404).json({ success: false, error: 'Not found' });
return;
}
if (req.path.startsWith('/mobile')) { if (req.path.startsWith('/mobile')) {
res.sendFile(path.join(publicDir, 'mobile/index.html'), (err) => { res.sendFile(path.join(publicDir, 'mobile/index.html'), (err) => {
if (err) next(); if (err) next();

View File

@@ -23,8 +23,7 @@
"web": { "web": {
"bundler": "metro", "bundler": "metro",
"output": "single", "output": "single",
"favicon": "./assets/images/favicon.png", "favicon": "./assets/images/favicon.png"
"baseUrl": "/mobile"
}, },
"plugins": [ "plugins": [
"expo-router", "expo-router",
@@ -32,7 +31,8 @@
"expo-web-browser" "expo-web-browser"
], ],
"experiments": { "experiments": {
"typedRoutes": true "typedRoutes": true,
"baseUrl": "/mobile"
} }
} }
} }