for more tech detail, see MDN CORS
Add this line to your Cargo.toml
toml
nickel_cors = "0.2.0"
It's simple.
```rust /* get server instance */ extern crate nickel; use nickel::Nickel; let mut server = Nickel::new();
/* enable cors */ extern crate nickelcors; server.utilize(nickelcors::enable_cors);
```
This middleware will add these CORS headers to your every response:
Access-Control-Allow-Methods: *
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
Access-Control-Max-Age: 86400
first you need install or switch to stable rust version.
shell
$ rustup default stable
runing test use under line, or it will be failed.
sh
cargo test -- --test-threads=1