Cannot build with the plugin http.cors

I have encountered a problem similar with Can't build with plugins

When I tried to build caddy with the http.cors plugin by following steps (from GitHub - caddyserver/caddy at v1), the cors plugin cannot be compiled in:

  1. Create a new folder and within a main.go file as:
package main

import (
	_ ""
        _ ""
func main() {
	// optional: disable telemetry
	// caddymain.EnableTelemetry = false
  1. Run go mod init caddy

  2. Run go get -u

  3. Run go build

After the Caddy binary generated, I ran ./caddy -plugins and didn’t see the http.cors plugin listed, however the http.forwardproxy plugin can be seen.

Now I have no idea the cause is from the Caddy or the http.cors plugin, so I am asking for help here, any advice would be appreciated. Thanks!

What is the full output of ./caddy -plugins?

Thanks for your reply. The output of ./caddy -plugins is like this:


Finally I found that the cors directive can be replaced by:

header / {
    Access-Control-Allow-Origin *

so I have given up installing http.cors plugins now. :joy:

One minor clarification:

-Server is not required, and the Server header has no bearing on CORS functionality whatsoever.

1 Like

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