File size: 833 Bytes
1177cc0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
Base URLs of the other services, read from the environment on every call (nothing hardcoded).

  MAIN_PROJECT_URL   the main project (ifind); comma-separated for several origins
  INTERNSCRAPER_URL  internScraper

Both are the browsers/services allowed to call this API from a web page (CORS). Unset = no browser origin is
allowed; server-to-server calls (ifind, internScraper) are not affected by CORS.
"""

import os
from typing import List


def _urls(name: str) -> List[str]:
    return [u for u in (p.strip().rstrip("/") for p in os.environ.get(name, "").split(",")) if u]


def main_project_urls() -> List[str]:
    return _urls("MAIN_PROJECT_URL")


def internscraper_urls() -> List[str]:
    return _urls("INTERNSCRAPER_URL")


def allowed_origins() -> List[str]:
    return [*main_project_urls(), *internscraper_urls()]