Azure / Azure/static-web-apps

Multiple SWA can't be on the same domain due since root endpoint can't be changed

Open
#1,096 9 comments 2 reactions 1 assignee Claimed by @thomasgauvin View on GitHub
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

**Multiple SWA can't be on the same domain due since root endpoint can't be changed**

TLDR: No possibility to serve application-x.azurestaticapps.net/.auth/* under application-x.azurestaticapps.net/\/.auth/* which leads to only one SWA being able to be served under one domain.

The easiest way to describe this is with an example:

Assume you have a domain example.com where we serve two applications: example.com/x and example.com/y. The proxy is done with an Application Gateway, so /x* goes to application-x.azurestaticapps.net and /y* goes to application-y.azurestaticapps.net, with header X-FORWARDED-FOR and X-ORIGINAL-HOST set by the proxy.

One solution is to serve the static files from a subdirectory _x_ and _y_ for each app. This would be fine, if you don't need authentication.

The authencation routes are served under application-x.azurestaticapps.net/.auth/*, and when behind the proxy this url becomes example.com/.auth which does not match any of our defined routes. Therefore the need to move the default /.auth files to /x/.auth becomes apparent.

**To Reproduce**
Steps to reproduce the behavior:
1. Create a SWA where the root is on a different page than /, e.g. application-x.azurestaticapps.net/app-x/
2. Have a proxy for example.com that answers on the route example.com/app-x and forwards to application-x.azurestaticapps.net/app-x/ with rewritten host.
3. Try to login: example.com/app-x/login

```json
{
"trailingSlash": "auto",
"routes": [
{
"route": "/app-x/login",
"rewrite": "/.auth/login/github"
},
{
"route": "/app-x/profile*",
"allowedRoles": ["authenticated"]
}
],
"responseOverrides": {
"401": {
"redirect": "/app-x/login",
"statusCode": 302
}
}
}
```

**Expected behavior**
Expected behavior is that more than one SWA can be created on the same domain, while supporting authentication.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.