4nth0 / golem

From a single config file Golem start a mock server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle CORS

4nth0 opened this issue · comments

Currently, Golem isn't able to handle CORS headers for the preflight request.
Preflight requests use the OPTIONS method to validate the ability of the third-party domain to fetch data.

CORS can be handled by service or by path.

By Service

port: "7171"
services: 
  - name: "Ping Server"
    http_config:
      cors: 
          origin: "*" | "${request.host}" | "https://mywebsite.com"
          methods: GET
      routes:
        "/ping": 
          body: '{"message": "pong!"}'

By Path

port: "7171"
services: 
  - name: "Ping Server"
    http_config:
      routes:
        cors: 
            origin: "*" | "${request.host}" | "https://mywebsite.com"
            methods: GET
        "/ping": 
          body: '{"message": "pong!"}'