yarbsemaj / sveltekit-adapter-lambda

An adapter to build a SvelteKit app into a lambda ready for deployment with lambda proxy via the Serverless Framework or CDK.
https://www.npmjs.com/package/@yarbsemaj/adapter-lambda
MIT License
77 stars 16 forks source link

Using cloudfront function to route to static assets #27

Open aidan-gee opened 1 year ago

aidan-gee commented 1 year ago

Hi,

I believe it would be cheaper / faster to use a cloudfront function to route to static assets rather than Lambda@edge in some cases. It may be beneficial to have the option to choose

yarbsemaj commented 1 year ago

I don't think the origin re-writing would is possible however, i think there may be a way around this. Watch this space!

falmar commented 1 year ago

I added 2 origins to cloudfront, one goes to lambda as default behavior (not @edge), changed sveltekit's config.kit.paths.assets to ${ORIGIn}/_assets the second origin has a origin_path of /_asset/* and it routes all static assets to the secondary origin "s3", if i understand correctly this how im serving static files from s3 instead of the lambda function itself