Skip to content

Commit aa36771

Browse files
authored
fix: do not rewrite /api and /data-api requests to SvelteKit (#162)
1 parent 0fe3eaa commit aa36771

File tree

14 files changed

+68
-4
lines changed

14 files changed

+68
-4
lines changed

.github/workflows/azure-static-web-apps-polite-desert-00b80111e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
4545
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
4646
app_location: '/demo' # App source code path
47-
api_location: 'demo/build/server' # Api source code path - optional
47+
api_location: 'demo/func' # Api source code path - optional
4848
output_location: 'build/static' # Built app content directory - optional
4949
# needed when we set CUSTOM_BUILD_COMMAND
5050
skip_api_build: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules/
22
coverage/
33
*.tgz
4+
.vscode/

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
CHANGELOG.md
22
coverage/
3+
build/
4+
.svelte-kit/
5+
sk_render/

demo/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ node_modules
1010
.output
1111
vite.config.js.timestamp-*
1212
vite.config.ts.timestamp-*
13+
sk_render/

demo/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ This is a repo demonstrating how to use [svelte-adapter-azure-swa](https://www.n
44

55
This demo uses the local version of the adapter to make testing unreleased changes easier. In your app, you should install `svelte-adapter-azure-swa` from npm.
66

7+
This demo also uses a custom Azure function to make testing that integration easier. If you do not need a custom Azure function, you do not need the `func/` folder or need to set the `apiDir` option in `svelte.config.js`.
8+
79
[Deployed demo](https://polite-desert-00b80111e.2.azurestaticapps.net/)
810

911
## Developing

demo/func/HelloWorld/function.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"bindings": [
3+
{
4+
"authLevel": "anonymous",
5+
"type": "httpTrigger",
6+
"direction": "in",
7+
"name": "req",
8+
"methods": ["get", "post"]
9+
},
10+
{
11+
"type": "http",
12+
"direction": "out",
13+
"name": "res"
14+
}
15+
]
16+
}

demo/func/HelloWorld/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = async function (context, req) {
2+
context.log('JavaScript HTTP trigger function processed a request.');
3+
4+
const name = req.query.name || (req.body && req.body.name);
5+
const responseMessage = name
6+
? 'Hello, ' + name + '. This HTTP triggered function executed successfully.'
7+
: 'This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.';
8+
9+
context.res = {
10+
// status: 200, /* Defaults to 200 */
11+
body: responseMessage
12+
};
13+
};

demo/func/HelloWorld/sample.dat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "Azure"
3+
}

demo/func/host.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"version": "2.0",
3+
"extensionBundle": {
4+
"id": "Microsoft.Azure.Functions.ExtensionBundle",
5+
"version": "[2.*, 3.0.0)"
6+
}
7+
}

demo/func/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)