Fix manifest URL generation for PWA apps with query parameter-based language codes#410
Fix manifest URL generation for PWA apps with query parameter-based language codes#410jsbalrog wants to merge 9 commits intofrontierMasterfrom
Conversation
|
So the real problem is that we are indiscriminately concatenating paths instead of using proper URL hygiene. Can we use |
The Problem
PWA apps using query parameter-based language codes (like
/africa?lang=en) were generating malformed manifest URLs, causing browser console errors. The issue occurred becauseappPath('')returns the full app path including query parameters (e.g.,/africa?lang=en), and the layout template was directly concatenating/manifest.json, resulting in invalid URLs like/africa?lang=en/manifest.jsoninstead of/africa/manifest.json.The Solution
We now strip query parameters from the app path before concatenating with
/manifest.jsonin the layout template.Before:
After:
Impact
/en/some-app) are unaffected as they don't have query parameters inappPath().IMPORTANT: Apps using this fix must also update their server.js to properly serve PWA assets and prevent redirects. Changes Required in client PWA App's
server.js:Why these changes are needed:
?lang=en.server.jsroutes, requests fall through to the catch-all SPA route, returning HTML instead of the actual files.PWA_ASSETSconstant (or similar) ensures the list is maintained in one place.Additional Context
FS_CLIENT_APP_LANG_QUERY_PARAM_PATHSenvironment variable) in an app's.envfile.