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

Content-Type of javascript files stored on s3 are returned with a Content-Type of text/html #24

Closed PVautour closed 1 year ago

PVautour commented 1 year ago

Hello,

I am getting an issue where my .js files are being blocked because they are returned with a Content-Type of text/html.

Here is the error log from Firefox:

Loading module from “https://22dj4azkgiqjznhqjiwors7tze0qoira.lambda-url.us-east-1.on.aws/_app/immutable/start-f4d7d7b9.js” was blocked because of a disallowed MIME type (“text/html”).

This is weird as the Content-Type is correctly set in s3. Here is the info from it:

METADATA: 
  Type: System defined
  Key: Content-Type
  Value: application/javascript

HTML files seem to be loading fine though. My guess is that the adapter may be looking at the MIME type, and not finding any and defaulting to text/html instead of looking at the Content-Type, however this is just and intuition and I haven't been able to confirm it by checking the code for the moment.

Does this seem like a user error or a software error?

Thank you for your time!

Pascal V.

yarbsemaj commented 1 year ago

Hi @PVautour thank-you for your interest in my project! From looking at the error, it would appear you you are trying to visit the lambda function URL rather that the url of the cloudfrount distribution. To find this url, visit the cloudfrount section of the aws console. if you visit this domain the site should be served correctly.

PVautour commented 1 year ago

Oh wow that certainly fixes the issue. Thanks a lot you really got me back on track! Software engineering can be quite humbling sometimes haha.

Everything works now, thanks for building the adapter and responding so fast, it's a life saver :)

Great day to you sir