Access-Control-Allow-Origin Actix-CORS

I have Rust-code running on and want to make a GET/POST request to it from rustsite.local (another domain).

However, that is not possible with CORS restriction. I find nowhere in the Actix-CORS documentation on how to allow Access-Control-Allow-Origin so specific domains can make requests to

Please try this:

use actix_cors::Cors;
use actix_web::{web, App, HttpResponse, HttpServer, Responder};

async fn hello_world() -> impl Responder {
    HttpResponse::Ok().body("Hello, World!")

async fn main() -> std::io::Result<()> {
    HttpServer::new(|| App::new().wrap(Cors::new()
    ).route("/hello", web::get().to(hello_world)))

Dependencies in Cargo.toml:

actix-cors = "0.3.0"
actix-web = "3"

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.