Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - spyder94

#1
General Discussion / Re: Enable CORS with Caddy plugin
August 10, 2025, 08:53:20 PM
And of course I get it to work minutes after posting. For those following, I modified @janstadt's code to the following (pretty sure the 4th line can be deleted):


(cors) {
  @cors_preflight method OPTIONS
  @cors_get method GET
  @cors header Origin {args.0}

  handle @cors_preflight {
    header Access-Control-Allow-Origin "{args.0}"
    header Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE"
    header Access-Control-Allow-Headers "Content-Type, x-api-key"
    header Access-Control-Max-Age "3600"
    respond "" 204
  }

  handle @cors_get {
    header Access-Control-Allow-Origin "{args.0}"
    header Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE"
    header Access-Control-Allow-Headers "Content-Type, x-api-key"
    header Access-Control-Expose-Headers "Link"
  }
}

[immich domain] {
  handle /api* {
    import cors [domain making the CORS call (homeassistant wallpanel)]
    reverse_proxy [ip:port of immich]
  }

  handle {

    reverse_proxy [ip:port of immich]
  }
}

#2
General Discussion / Re: Enable CORS with Caddy plugin
August 10, 2025, 08:16:47 PM
@janstadt I'm in this exact scenario. I can see in the browser console that your code works for correcting the preflight call, but I'm still getting the CORS error for the actual fetch calls. It doesn't appear that any headers are getting set on the fetch responses. Any insight?