getlift / lift

Expanding Serverless Framework beyond functions using the AWS CDK
MIT License
912 stars 111 forks source link

SinglePageApp should support .wasm files #331

Closed AtteR closed 1 year ago

AtteR commented 1 year ago

Start from the Use-case

Hello,

Currently CloudFront request function redirects .wasm files to /index.html (https://github.com/getlift/lift/blob/master/src/constructs/aws/SinglePageApp.ts#L48)

This makes the .wasm files load as HTML, which means that .wasm file is not loaded properly.

Adding wasm to REDIRECT_INDEX seems to fix this problem.

Example Config

No response

Implementation Idea

Add wasm to REDIRECT_REGEX:

var REDIRECT_REGEX = /^[^.]+$|.(?!(css|gif|ico|jpg|jpeg|js|png|txt|svg|woff|woff2|ttf|map|json|webp|xml|pdf|webmanifest|avif|wasm)$)([^.]+$)/;

This seems to fix the issue.

mnapoli commented 1 year ago

Hi, thanks for the report, feel free to send a pull request.