azure-dev: Start api in vscode failed when run vscode tests in todo-python-mongo-swa-func
Describe the issue:
Run task Start API and Web
successfully.
But, when open the web site, the page keeps loading. The error is as follows:
Repro Steps:
- Run
bash ./test-templates.sh -t todo-python-mongo-swa-func -b staging -c false
- Open the project in VS Code
- Hit F1, Run Task, Start API and Web
Environment:
- OS:
Linux desktop
andDev container
in VS Code: - Template: https://github.com/azure-samples/todo-python-mongo-swa-func
- Branch: staging
- Azd version: 0.3.0-beta.6-daily.1947218 (commit https://github.com/Azure/azure-dev/commit/e20ee4e6819f464f1f19d768d62bfaef493d46d8)
Remark:
Issue1 only occurs in Dev container
in VS Code, and Issue2 occurs in both Linux desktop
and Dev container
in VS Code.
Expected behavior: Start api in vscode successfully when run vscode tests.
@rajeshkamal5050 for notification.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 21 (17 by maintainers)
The issue about CORS is root caused to the task
Start Functions
It runs"command": "host start --port 3100 --cors *",
where cors is ignored.So the Function is started by it sets CORS to deny all origins. This is why this is only reproducible by running
Start API
and not when runningDebug API
, since runningDebug API
uses python directly to start the API instead of hosting the API in a simulated Azure Function (likeStart API
does).Changing the command to:
"command": "host start --port 3100 --cors '*'",
fixes the issue, as it starts the Function allowing all CORS.I will create a PR for this.
The CORS issue was reported with the current templates, so it shouldn’t be blocking for the release. We can always also ship out a template release, so we shouldn’t be blocking CLI on it. I’ll confirm the behavior though.
The issue is not always reproducible because it will happen only when the expiration time contains microseconds.
I will create a new issue for that.