microsoft / microsoft/vscode-azureresourcegroups
[Bug Bash] Generated SWA App didn't fully work
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 78
- Forks
- 55
- Avg merge
- 16h 49m
- Merged PRs (30d)
- 139
Description
The website loaded, but has this error at the bottom of the main UI: Couldn't loadFailed to mint dev token: HTTP 404
I asked Copilot to fix it, which it did, and said this was the problem.
SPA hardcoded /api/* paths — liveClient.ts called fetch('/api/auth/token', ...) as a same-origin path. Since the SPA is served from thankful-meadow-0373d930f.5.azurestaticapps.net, that resolved to SWA's managed-API route (which doesn't exist on Free tier) → 404. VITE_API_BASE_URL was baked into the bundle but never read. Fixed by introducing an apiUrl() helper that prepends VITE_API_BASE_URL (or falls back to /api for the Vite dev proxy).
authTokenDev returned 404 because NODE_ENV=production — authToken.ts treated the standard prod signal as the kill switch. Even if problem #1 hadn't existed, the endpoint would still 404 in production. Switched the gate to a dedicated ALLOW_DEV_AUTH=true app setting (wired into function-app.bicep), so NODE_ENV=production can stay set correctly.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the SPA request logic in liveClient.ts, the development-token handling in authToken.ts, and the deployment setting in function-app.bicep. Reproduce the generated SWA app failure and verify that the deployed API request reaches its configured endpoint and that development token minting succeeds without breaking production configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, typescript, vite
- Domain
- api, cloud, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100