-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to set wildcard route #65
Comments
There is an open PR to allow setting I was waiting for the original author to resolve some comments I made on the PR, though I can clean up the PR myself since it's been a few weeks. |
Ahh, sorry I didn't notice that before. That pull request would not do what I need it to do, and it might interfere if you use a map function to replace the What I described would give developers the freedom to write routes as described by Microsoft's documentation, with the adapter doing a little cleanup to make sure they run correctly. That cleanup could include inserting an I would also ask to let rules be written with a |
Please take a look at my pull request when you get a minute. It might actually serve as a replacement to #60 because a default import azure from 'svelte-adapter-azure-swa';
export default {
kit: {
...
adapter: azure({
customStaticWebAppConfig: {
routes: [
{
route: '/*',
allowedRoles: ['admin']
}
],
globalHeaders: {
'X-Content-Type-Options': 'nosniff',
'X-Frame-Options': 'DENY',
'Content-Security-Policy': "default-src https: 'unsafe-eval' 'unsafe-inline'; object-src 'none'",
},
mimeTypes: {
'.json': 'text/json'
},
responseOverrides: {
'401': {
'redirect': '/login',
'statusCode': 302
}
}
}
})
}
}; The adapter then uses that wildcard route's settings to override the settings of all routes it creates. |
Great, thank you. I should hopefully be able to take a look in the next few days. |
I have an app that needs all users to be authenticated. There is no public-facing welcome page and no need for one. All users should redirect automatically to
/.auth/login/aad
if they aren't authenticated.The way I see it, there are two main ways to handle this. Either check for the
x-ms-client-principal
header in a hook and throw an error if it's missing, or setallowedRoles
for all routes instaticwebapp.config.json
. I would prefer the latter option because then pre-rendered pages will be protected without having to make all pages server-side rendered.Unfortunately, that's not possible because of the way this adapter processes the config.
The workaround seems to be to list each route in the adapter's
customStaticWebAppConfig
, but that has two problems: The first problem is the hook still has to be used to protect the routes that get added automatically. The second problem is there are now two sources of truth for the list of routes. The file system andsvelte.config.js
.I understand there is a need to rewrite routes to
ssrFunctionRoute
for server-side rendering, but perhaps there could be a more nuanced way of building the route map other than just tacking on permanent routes and blocking wildcard routes. For example, the providedcustomStaticWebAppConfig
could be walked and rules that lack aredirect
andrewrite
could have arewrite: ssrFunctionRoute
added. Then, if the required routes are missing, they could be added.Are you receptive to a pull request on this subject? I might be willing to take a stab at it.
The text was updated successfully, but these errors were encountered: