Skip to content
Playground(another site)

bynk.http.cookie_cross_site_without_credentials

Warning A service attaches a SameSite.Unrestricted cookie but declares no cors { credentials: true }, so a cross-origin fetch can never send it back (warning).

A cookie with SameSite=None (SameSite.Unrestricted) exists to travel on cross-site requests, and a browser attaches cookies to a cross-origin fetch only when the request is credentialed and the response carries Access-Control-Allow-Credentials: true. A service with no cors policy, or one with credentials: false, never sends that header, so a cross-origin fetch can never send the cookie back. This is a warning, because a SameSite=None cookie is still sent on top-level cross-site navigations, cross-site form posts and in embeds (SSO and payment callbacks, widgets), none of which needs CORS. If a page on another origin must send it back with fetch, declare cors { origins: [...], credentials: true } (the origins must be exact, not ["*"]), or use SameSite.Lax if the cookie need not cross sites at all.

Example

service api from http {
on POST("/login") () -> Effect[HttpResult[String]] by v: Visitor {
Created("ok").withCookie(Cookie { name: "sid", value: "a", sameSite: SameSite.Unrestricted }) // ⚠ no `cors { credentials: true }`
}
}
service api from http {
cors { origins: ["https://app.example.com"], credentials: true } // ✓
…
}

In the Book

See also

  • The grammar rule it governs: http_handler.
  • Every code in its category, HTTP, on the diagnostic index.
  • bynk explain bynk.http.cookie_cross_site_without_credentials shows the same from the installed toolchain, without a network.