https://kotlinlang.org logo
#kotless
Title
# kotless
p

PJ Walstrom

10/18/2020, 8:16 PM
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

TanVD

10/18/2020, 8:53 PM
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

PJ Walstrom

10/18/2020, 9:09 PM
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

TanVD

10/19/2020, 7:18 AM
Yep, js and css on that site is also static resources. Does it work for you? Maybe the problem is with binary files
p

PJ Walstrom

10/19/2020, 8:27 AM
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

TanVD

10/19/2020, 1:41 PM
hmm, for me it loads...
Or what do you mean?
p

PJ Walstrom

10/19/2020, 1:42 PM
yes, but the css is not in effect. Locally it is lightblue, on AWS it is not
t

TanVD

10/19/2020, 1:53 PM
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

PJ Walstrom

10/19/2020, 1:58 PM
Will check tonight, currently out biking 🙂🚴
👍 1
t

TanVD

10/19/2020, 9:12 PM
Where is the main HTML located?)
p

PJ Walstrom

10/20/2020, 6:22 AM
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

TanVD

10/20/2020, 2:19 PM
I'll have to check, the problem is due to no domain used 😞
p

PJ Walstrom

10/21/2020, 2:51 PM
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

TanVD

10/21/2020, 8:57 PM
It should have been working without CloudFront 😞 Could you file an issue please?
p

PJ Walstrom

10/22/2020, 8:48 AM
You mean file an issue for Kotless, or AWS?
t

TanVD

10/22/2020, 9:36 AM
To Kotless)
✔️ 1
2 Views