Skip to content
Playground(another site)

bynk.parse.duplicate_cors

Error A service declares more than one cors { } policy.

A service has one CORS policy, and it applies to every route in it. Two cors blocks could grant different things, and the reader would not know which holds, so the second is refused. Merge them into one. security and limits follow the same rule (bynk.parse.duplicate_security, bynk.parse.duplicate_limits), as does json (bynk.parse.duplicate_json).

Example

service api from http {
cors { origins: ["https://a.example"] }
cors { origins: ["https://b.example"] } // ✗ a second `cors`
on GET("/a") () -> Effect[HttpResult[Int]] by Visitor { … }
}
service api from http {
cors { origins: ["https://a.example", "https://b.example"] } // ✓ one policy
on GET("/a") () -> Effect[HttpResult[Int]] by Visitor { … }
}

In the Book

See also

  • The grammar rule it governs: service_decl.
  • Every code in its category, Parser, on the diagnostic index.
  • bynk explain bynk.parse.duplicate_cors shows the same from the installed toolchain, without a network.