I am getting error Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://some-domain/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 502."

1. The problem I’m having:

I am using Caddy and when I go to domain https://some-domain it works but when i route to path /routes it gives me error .

2. Error messages and/or full log output:

When i hit https://some-domain/routes i get error which says "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://some-domain/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 502."

Caddy config

kong.{$DOMAIN_NAME} {
    reverse_proxy kong:8000
}

# Kong Admin APIs
kong-api.{$DOMAIN_NAME} {
    reverse_proxy kong:8001
}

# Kong Admin GUI
kong-admin.{$DOMAIN_NAME} {
    reverse_proxy kong:8002
}

caddy.{$DOMAIN_NAME} {
    reverse_proxy caddy:443
}

compose file

version: '3.8'

services:
  caddy:
    image: caddy:latest
    container_name: caddy
    cap_add:
      - NET_ADMIN
    ports:
      - "80:80"
      - "443:443"
    environment:
      DOMAIN_NAME: ${DOMAIN_NAME}
    volumes:
      - ./caddy/Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config
  
  kong:
    image: kong:3.6.1
    container_name: kong
    user: kong
    environment:
      KONG_DATABASE: ${KONG_DATABASE:-off}
      KONG_ADMIN_ACCESS_LOG: /dev/stdout
      KONG_ADMIN_ERROR_LOG: /dev/stderr
      KONG_PROXY_ACCESS_LOG: /dev/stdout
      KONG_PROXY_ERROR_LOG: /dev/stderr
      KONG_ADMIN_GUI_URL: https://kong-admin.${DOMAIN_NAME}
      KONG_ADMIN_GUI_API_URL: https://kong-api.${DOMAIN_NAME}
      KONG_PREFIX: ${KONG_PREFIX:-/usr/local/kong}
      KONG_DECLARATIVE_CONFIG: "/opt/kong/kong.yaml"
    healthcheck:
      test: [ "CMD", "kong", "health" ]
      interval: 10s
      timeout: 10s
      retries: 10
    restart: always
    volumes:
      - kong:${KONG_PREFIX:-/usr/local/kong}
      - ./kong/:/opt/kong
      - ./kong/kong.conf:/etc/kong/kong.conf

volumes:
  caddy_data:
  caddy_config:
  kong:

and I am using docker-compose to run it

Hey @francislavoie can you please help

CORS issues are typically application-level issues, not a problem with Caddy. You should ask for help from the Kong project I guess.

Thanks for the response

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.