Skip to content

Commit

Permalink
Fix for known api gateway issue with actions and updated cdk
Browse files Browse the repository at this point in the history
  • Loading branch information
yarbsemaj committed Jun 12, 2024
1 parent 354bf5a commit 6a5ffb7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion SvelteKitSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ export class SvelteKitSite extends Construct {
}))

const forwardHeaderFunction = new cdk.aws_cloudfront.Function(this, `${id}-forward-header-function`, {
code: cdk.aws_cloudfront.FunctionCode.fromInline('function handler(event) { return event.request }'),
code: cdk.aws_cloudfront.FunctionCode.fromInline(`function handler(event) {
event.request.headers['x-forwarded-host'] = event.request.headers['host']
return event.request
}`),
});

new cdk.aws_s3_deployment.BucketDeployment(this, `${id}-deploy-prerender`, {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yarbsemaj/adapter-lambda",
"version": "1.2.0",
"version": "1.2.1",
"license": "MIT",
"description": "An adapter for [SvelteKit](https://kit.svelte.dev/) for AWS Lambda. [Serverless](https://www.serverless.com/) or [CDK](https://aws.amazon.com/cdk/) deployment.",
"repository": {
Expand Down
3 changes: 3 additions & 0 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import staticFiles from './static.js'
exports.handler = (event, context, callback) => {
const request = event.Records[0].cf.request;

//Fix for sveltekit action urls
request.querystring = request.querystring.replace('/', '%2F');

//Only send GET request to S3
if (request.method !== 'GET') {
callback(null, request);
Expand Down

0 comments on commit 6a5ffb7

Please sign in to comment.