Skip to content

Commit 4c40826

Browse files
kunjee17LegNeato
andauthored
explicit origin is required with new CORS (#802)
Co-authored-by: Christian Legnitto <[email protected]>
1 parent 2008960 commit 4c40826

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

juniper_actix/examples/actix_server.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::env;
44

55
use actix_cors::Cors;
6-
use actix_web::{middleware, web, App, Error, HttpResponse, HttpServer};
6+
use actix_web::{http::header, middleware, web, App, Error, HttpResponse, HttpServer};
77
use juniper::{
88
tests::fixtures::starwars::schema::{Database, Query},
99
EmptyMutation, EmptySubscription, RootNode,
@@ -49,7 +49,10 @@ async fn main() -> std::io::Result<()> {
4949
.wrap(middleware::Logger::default())
5050
.wrap(
5151
Cors::default()
52+
.allowed_origin("http://127.0.0.1:8080")
5253
.allowed_methods(vec!["POST", "GET"])
54+
.allowed_headers(vec![header::AUTHORIZATION, header::ACCEPT])
55+
.allowed_header(header::CONTENT_TYPE)
5356
.supports_credentials()
5457
.max_age(3600),
5558
)

0 commit comments

Comments
 (0)