1. The problem I’m having:
I deployed a new react.js application in /opt/fe/website (/demo/), but it is giving error messages. It is working on localhost.
Since the error message is about wrong mimetype, I tried to define them manually, but in that case, caddy does not start, without error details.
Where can I define the mime types ?
Or is something else causing the issue ?
handle /demo/ {
root * /opt/fe/website
try_files {path} /index.html
file_server
mime .css text/css
}
2. Error messages and/or full log output:
Caddy error:
Job for caddy.service failed because the control process exited with error code.
See “systemctl status caddy.service” and “journalctl -xeu caddy.service” for details.
Browser error:
“Failed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of “text/html”. assets/index-BGSeMjDe.js
3. Caddy version:
v2.10.2
4. How I installed and ran Caddy:
Started with systemctl start caddy.
a. System environment:
Caddy is on a linux ubuntu server (24.04.2 LTS).
b. Command:
systemctl restart caddy
c. Service/unit/compose file:
No docker.
d. My complete Caddy config:
qcg-ai.ch www.qcg-ai.ch {
encode
templates
handle /demo/ {
root * /opt/fe/website
try_files {path} /index.html
file_server
#mime .css text/css
}
handle /demo {
redir * /demo/
}
handle /api/* {
uri strip_prefix /api
reverse_proxy localhost:8080 {
health_uri /ping
health_port 8080
health_interval 30s
health_timeout 30s
#header_up X-API-Key {env.API_KEY}
}
}
handle /api {
redir * /api/
}
handle {
root * /opt/fe/dev
try_files {path} /index.html
file_server
}
tls info@inss.ch
log {
output file /var/log/caddy/access.log
format json
}
}
PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.