Caddy not getting mime types on OSX

1. Caddy version (caddy version):


2. How I run Caddy:

I use a caddyfile in my project’s directory. I want to reverse proxy my frontend dev server to and my backend dev server to, so I can keep credentials.

a. System environment:

macOS (Darwin) Monterry
installed caddy with homebrew
populated mime files (so locate mime works fully)

b. Command:

sudo caddy run

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.

d. My complete Caddyfile or JSON config:

localhost {
        reverse_proxy / localhost:3000

3. The problem I’m having:

I do not get a Content-Type header on any of the responses:

> GET / HTTP/2
> Host: localhost
> user-agent: curl/7.77.0
> accept: */*
* Connection state changed (MAX_CONCURRENT_STREAMS == 250)!
< HTTP/2 200 
< access-control-allow-origin: *
< content-type: text/html
< date: Wed, 10 Nov 2021 23:58:42 GMT
< etag: "uhl6ls"
< permissions-policy: interest-cohort=()
< server: Caddy
{ [5926 bytes data]
100 69622    0 69622    0     0  1573k      0 --:--:-- --:--:-- --:--:-- 1942k
* Connection #0 to host localhost left intact

and my html is sent back fine.
If I try GET /.svelte-kit/dev/runtime/internal/start.js

> GET /.svelte-kit/dev/runtime/internal/start.js HTTP/2
> Host: localhost
> user-agent: curl/7.77.0
> accept: */*
* Connection state changed (MAX_CONCURRENT_STREAMS == 250)!
< HTTP/2 200 
< server: Caddy
< content-length: 0
< date: Thu, 11 Nov 2021 00:01:44 GMT
{ [0 bytes data]

and on the original port:

> GET /.svelte-kit/dev/runtime/internal/start.js HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.77.0
> Accept: */*
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: application/javascript
< Cache-Control: no-cache
< Etag: W/"7317-UkQK1ywFABk5Fa3QUizL7LYMeA8"
< Date: Thu, 11 Nov 2021 00:01:59 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
< Content-Length: 29463
{ [29463 bytes data]

The latter has the Content-Type header, which I need.

4. Error messages and/or full log output:

5. What I already tried:

I’ve populated my MIME entries.
I’ve built caddy from source
I’ve installed caddy from home-brew and the GitHub

6. Links to relevant resources:

You’re only proxying requests to / – is that intentional?

1 Like

As @matt astutely observes, for a request to /.svelte-kit/dev/runtime/internal/start.js, Caddy has no configuration.

For this request, an empty 200 OK response is expected behaviour.

For your request to /, I can see you received content-type: text/html passed through from the proxy. To clarify, Caddy’s behaviour is to preserve upstream headers, so if the request was proxied, and the proxy returned a content-type header, it should show on Caddy’s response unless you have configured it otherwise. In your case, the longer request was not proxied. Try proxying * (catch-all) instead of literal /.

I might also suggest here that you update it as well - current Homebrew distribution of Caddy should produce a proper result for caddy version, so you probably have an older version.


this fixed it, thanks.
I have a new issue, but it’s not directly caddy related.
The frontend keeps refreshing if I connect to the caddy server, but is fine on its original port
Thanks for all the help :slight_smile:

For those who may find this on google:

I ended up not using caddy. I modified my /etc/hosts file to map to
I used Vite’s internal https and everything worked.

I believe the problem was with caddy not proxying wss:// to ws://, but I’m a bit out of my depth here (!)

This topic was automatically closed after 30 days. New replies are no longer allowed.