1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-26 07:19:22 +00:00

Add Access-Control-Allow-Origin Header for admin requests

This commit is contained in:
Pierre HUBERT 2021-05-11 19:01:25 +02:00
parent d141902997
commit cf5ed7ddde
2 changed files with 7 additions and 2 deletions

View File

@ -71,7 +71,7 @@ rtc-relay:
max-users-per-video-calls: 6
# Admin URL
admin-url: https://console.communiquons.org
admin-url: http://localhost:3001
# List of #Forez groups
#

View File

@ -13,7 +13,7 @@ use crate::data::base_request_handler::{BaseRequestHandler, RequestValue};
use crate::data::config::conf;
use crate::data::error::{Res, ResultBoxError};
use crate::data::user_token::UserAccessToken;
use crate::helpers::{account_helper, api_helper, admin_access_token_helper};
use crate::helpers::{account_helper, admin_access_token_helper, api_helper};
use crate::routes::RequestResult;
/// Http request handler
@ -137,6 +137,11 @@ impl HttpRequestHandler {
pub fn check_admin_origin(&mut self) -> Res {
if let Some(header) = self.request.headers().get("Origin") {
if header.to_str()?.eq(&conf().admin_url) {
self.headers.insert(
"Access-Control-Allow-Origin".to_string(),
conf().admin_url.to_string(),
);
return Ok(());
}
}