How do I get static resources to work on AWS? I us...
# kotless
p
How do I get static resources to work on AWS? I use
Copy code
@StaticGet("/favicon.ico", MimeType.PNG)
val favicon = File("favicon.ico")
The resource is deployed to S3, but it is not accessible. Locally, it works, though. I see the same problems with e.g. https://ktor.short.kotless.io/favicon.apng and https://ktor.site.kotless.io/favicon.apng
t
In your case actual problem is that you are deploying
ico
as
png
probably. From Safari kotless examples been working ok, but from Chrome I see some error with headers...
p
Same problem if it is png or ico. Can't get the kotless examples to work on Safari either, maybe cached at your side? Are there any examples with other static resources except from favicons?
t
Yep, js and css on that site is also static resources. Does it work for you? Maybe the problem is with binary files
p
I'll test with some non-binary resources
Can't get non-binary to work, either. CSS not loaded, even though it is there https://vikxi5gyvl.execute-api.eu-north-1.amazonaws.com/1/kotless-test.css works fine with
./gradlew local
, though
t
hmm, for me it loads...
Or what do you mean?
p
yes, but the css is not in effect. Locally it is lightblue, on AWS it is not
t
Hm, do you have a dns record? And what url do you use for test?)
Could you check that links in html to css are correct?
p
Will check tonight, currently out biking 🙂🚴
👍 1
t
Where is the main HTML located?)
p
I used HTML DSL in the mentioned Main.kt, and it all ends up here https://vikxi5gyvl.execute-api.eu-north-1.amazonaws.com/1
t
I'll have to check, the problem is due to no domain used 😞
p
When I use a domain, both binary and non-binary static resources works fine in Safari [1]. If I right click a picture and choose "Open Image in New Tab" [2], the picture is not shown, though. Which really makes little sense! In Chrome, only non-binary static resources are displayed. Which also makes little sense... refs [1] https://www.waperon.org [2]

https://www.waperon.org/fjell.jpg

Maybe a Cloudfront Distribution would solve this problem? Would that be possible to achieve with Terraform? https://aws.amazon.com/getting-started/hands-on/deliver-content-faster/
t
It should have been working without CloudFront 😞 Could you file an issue please?
p
You mean file an issue for Kotless, or AWS?
t
To Kotless)
✔️ 1