1
0
mirror of https://github.com/actix/examples synced 2025-06-26 17:17:42 +02:00

fix vue example ports

closes #624
This commit is contained in:
Rob Ede
2023-07-17 22:26:11 +01:00
parent da976e0415
commit f3cf37bb0d
5 changed files with 151 additions and 116 deletions

View File

@ -1,5 +1,5 @@
[package]
name = "actix-web-cors"
name = "cors"
version = "1.0.0"
edition = "2021"
@ -8,5 +8,6 @@ actix-web = { workspace = true, features = ["rustls"] }
actix-cors.workspace = true
env_logger.workspace = true
serde = { version = "1.0", features = ["derive"] }
log.workspace = true
serde.workspace = true
serde_json.workspace = true

View File

@ -1,17 +1,21 @@
use std::io;
use actix_cors::Cors;
use actix_web::{http::header, middleware::Logger, App, HttpServer};
mod user;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
async fn main() -> io::Result<()> {
env_logger::init_from_env(env_logger::Env::default().default_filter_or("info"));
log::info!("starting HTTP server at http://localhost:8080");
HttpServer::new(move || {
App::new()
.wrap(
Cors::default()
.allowed_origin("http://localhost:8080")
.allowed_origin("http://localhost:8081")
.allowed_methods(vec!["GET", "POST"])
.allowed_headers(vec![header::AUTHORIZATION, header::ACCEPT])
.allowed_header(header::CONTENT_TYPE)