Configure Cross-Origin Resource Sharing (CORS)
Arguments
- enabled
Enable or disable CORS (default FALSE)
- origins
Allowed origins. Use "*" for any origin, or provide a character vector of specific domains (default "*")
- methods
HTTP methods to allow (default includes common methods)
- headers
Headers to allow in requests (default includes common headers)
- credentials
Allow credentials in cross-origin requests (default FALSE)
- max_age
Maximum time (in seconds) browsers should cache preflight results (default 86400 = 24 hours)
Examples
if (interactive()) {
# Enable CORS for all origins
payload_cors_config(enabled = TRUE)
# Restrict to specific origins
payload_cors_config(
enabled = TRUE,
origins = c("https://myapp.com", "https://staging.myapp.com"),
credentials = TRUE
)
# Disable CORS
payload_cors_config(enabled = FALSE)
}
