~erutuon/enwiktionary-translations-server

39e25455014a51d67f46e3acace98a6e3cd429f6 — Erutuon 2 years ago 8824bc0
allow cross-origin requests

I'm not sure this is right because I still don't
understand CORS.
1 files changed, 7 insertions(+), 0 deletions(-)

M src/main.rs
M src/main.rs => src/main.rs +7 -0
@@ 10,7 10,9 @@ use bstr::ByteSlice;
use regex::{Captures, Regex, Replacer};
use rusqlite::{functions::FunctionFlags, Connection, OpenFlags};
use tide::{
    http::headers::HeaderValue,
    log::{self, debug, LevelFilter, LogMiddleware},
    security::{CorsMiddleware, Origin},
    utils::After,
    Response, StatusCode,
};


@@ 275,6 277,11 @@ async fn main() -> tide::Result<()> {
            }
        }
    }));
    let cors = CorsMiddleware::new()
        .allow_methods("GET".parse::<HeaderValue>().unwrap())
        .allow_origin(Origin::from("*"))
        .allow_credentials(false);
    app.with(cors);
    app.listen(args.addr).await?;
    Ok(())
}