Skip to content

Latest commit

 

History

History

cors

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Cross-Origin Resource Sharing for bunrouter

To run this example:

go run main.go

To test that CORS are allowed from localhost:

curl -H "Origin: http://localhost:9999" \
  -H "Access-Control-Request-Method: POST" \
  -X OPTIONS \
  --verbose \
  http://localhost:9999/api/v1/users/123

To test that CORS are restricted from other domains:

curl -H "Origin: https://uptrace.dev" \
  -H "Access-Control-Request-Method: POST" \
  -X OPTIONS \
  --verbose \
  http://localhost:9999/api/v1/users/123

See documentation for details.