-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The serveDirectory
middleware sends JS files as application/javascript
(3.0.0-RC7)
#2855
Comments
It seems that the main issue is the absence of the |
/bounty $50 |
💎 $50 bounty • ZIOSteps to solve:
Thank you for contributing to zio/zio-http! Add a bounty • Share on socials
|
💡 @987Nabil submitted a pull request that claims the bounty. You can visit your bounty board to reward. |
🎉🎈 @987Nabil has been awarded $50! 🎈🎊 |
Describe the bug
The
serveDirectory
middleware sends JS files asapplication/javascript
, whereas i.ecaddy
working as a file server sends them astext/javascript; charset=utf-8
.To Reproduce
Steps to reproduce the behaviour:
public
with at least one JavaScript fileMiddleware.serveDirectory(Path.empty, new File("public"))
caddy file-server --listen :9000 --root public/
Expected behaviour
It seems that the main difference between Caddy and ZIO HTTP is
content-type
. I suspect that if ZIO HTTP sends the same content type, the browser will execute JS without a problem.Screenshots
![character-error](https://private-user-images.githubusercontent.com/3617707/331900926-ac47f26f-e9dd-4504-8659-76f91f486ff9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4NDAyNDcsIm5iZiI6MTcyMzgzOTk0NywicGF0aCI6Ii8zNjE3NzA3LzMzMTkwMDkyNi1hYzQ3ZjI2Zi1lOWRkLTQ1MDQtODY1OS03NmY5MWY0ODZmZjkucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgxNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdG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y-content-type](https://private-user-images.githubusercontent.com/3617707/331901325-ceca3854-8da0-4752-936c-5783551ace1f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4NDAyNDcsIm5iZiI6MTcyMzgzOTk0NywicGF0aCI6Ii8zNjE3NzA3LzMzMTkwMTMyNS1jZWNhMzg1NC04ZGEwLTQ3NTItOTM2Yy01NzgzNTUxYWNlMWYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgxNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MTZUMjAyNTQ3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Zjc2N2MyMmZjZGQ2OTk0YmYzYzlmZjY3Y2U5ZTZiNGMwZWFmMjUzNjQ0ZmM5ZmQwNmNmNzk0ZTgyYzBlOWI2NSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.6NCMbgj-h2EslGJFOuvCXL3Z7XVHqgLN-mpowkv0vkc)
See the error in the attached screenshot.
Desktop (please complete the following information):
Additional context
The JS in question is a bundle that contains JSX and all kinds of stuff, but I suspect the problem might occur with any JS file. I'm using ZIO HTTP 3.0.0-RC7.
The text was updated successfully, but these errors were encountered: