Enable CORS on server

Hi Caddy again,

1. The problem I’m having:

This time I am trying to enable the CORS on my caddy server. To make this easy I will put the last help url in here then I can go directly to my issue without explain how I have configured my caddy server on digitalocean. so here is the link

So in this case I am trying integrate payment gateway here so it’s calling to third party service. When I call this third party service I am getting CORS issue like this on browser console

2. Error messages and/or full log output:

payhere.js:1 Access to XMLHttpRequest at 'https://www.payhere.lk/pay/checkoutJ' from origin 'https://www.chemmyfashion.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

payhere.js:1 POST https://www.payhere.lk/pay/checkoutJ net::ERR_FAILED 500

Main Caddy server logs :


{
  "level": "info",
  "ts": 1693734625.087928,
  "logger": "http.log.access.log3",
  "msg": "handled request",
  "request": {
    "remote_ip": "108.162.226.219",
    "remote_port": "12996",
    "proto": "HTTP/2.0",
    "method": "POST",
    "host": "www.chemmyfashion.com",
    "uri": "/api/orders/validate/productAvailabilityAndUpdateStockCount",
    "headers": {
      "Cf-Ipcountry": [
        "SG"
      ],
      "Cf-Visitor": [
        "{\"scheme\":\"https\"}"
      ],
      "Accept": [
        "application/json, text/plain, */*"
      ],
      "Content-Type": [
        "application/json"
      ],
      "Referer": [
        "https://www.chemmyfashion.com/order/cb38a0da-e349-432a-b784-08d558e367ec"
      ],
      "Accept-Language": [
        "en-US,en;q=0.9,ja;q=0.8"
      ],
      "Sec-Fetch-Dest": [
        "empty"
      ],
      "Cf-Ray": [
        "800d169dcaf744b5-SIN"
      ],
      "Content-Length": [
        "68"
      ],
      "Sec-Ch-Ua-Mobile": [
        "?0"
      ],
      "Authorization": [],
      "Sec-Ch-Ua-Platform": [
        "\"macOS\""
      ],
      "Origin": [
        "https://www.chemmyfashion.com"
      ],
      "Cdn-Loop": [
        "cloudflare"
      ],
      "Cf-Connecting-Ip": [
        "121.6.238.133"
      ],
      "Accept-Encoding": [
        "gzip"
      ],
      "X-Forwarded-For": [
        "121.6.238.133"
      ],
      "X-Forwarded-Proto": [
        "https"
      ],
      "Sec-Ch-Ua": [
        "\"Chromium\";v=\"116\", \"Not)A;Brand\";v=\"24\", \"Google Chrome\";v=\"116\""
      ],
      "User-Agent": [
        "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
      ],
      "Sec-Fetch-Site": [
        "same-origin"
      ],
      "Sec-Fetch-Mode": [
        "cors"
      ],
      "Priority": [
        "u=1, i"
      ]
    },
    "tls": {
      "resumed": false,
      "version": 772,
      "cipher_suite": 4865,
      "proto": "h2",
      "server_name": "www.chemmyfashion.com"
    }
  },
  "user_id": "",
  "duration": 0.061443056,
  "size": 17,
  "status": 200,
  "resp_headers": {
    "Etag": [
      "W/\"11-l8wg2b6ZqrDsZYSOZdfjskF4jXM\""
    ],
    "X-Powered-By": [
      "Express"
    ],
    "Content-Type": [
      "application/json; charset=utf-8"
    ],
    "Access-Control-Allow-Credentials": [
      "true"
    ],
    "Access-Control-Expose-Headers": [
      "*"
    ],
    "Content-Length": [
      "17"
    ],
    "Server": [
      "Caddy",
      "Caddy"
    ],
    "Alt-Svc": [
      "h3=\":443\"; ma=2592000"
    ],
    "Date": [
      "Sun, 03 Sep 2023 09:50:25 GMT"
    ],
    "Access-Control-Allow-Origin": [
      "https://www.chemmyfashion.com"
    ]
  }
}

Frontend application Caddy Server logs :


{
  "level": "info",
  "ts": 1693734625.0873108,
  "logger": "http.log.access.log0",
  "msg": "handled request",
  "request": {
    "remote_ip": "172.18.0.2",
    "remote_port": "34762",
    "proto": "HTTP/1.1",
    "method": "POST",
    "host": "www.chemmyfashion.com",
    "uri": "/api/orders/validate/productAvailabilityAndUpdateStockCount",
    "headers": {
      "Cf-Visitor": [
        "{\"scheme\":\"https\"}"
      ],
      "Priority": [
        "u=1, i"
      ],
      "Referer": [
        "https://www.chemmyfashion.com/order/cb38a0da-e349-432a-b784-08d558e367ec"
      ],
      "Sec-Ch-Ua-Mobile": [
        "?0"
      ],
      "Sec-Fetch-Dest": [
        "empty"
      ],
      "User-Agent": [
        "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
      ],
      "Accept-Encoding": [
        "gzip"
      ],
      "Cf-Ipcountry": [
        "SG"
      ],
      "Content-Type": [
        "application/json"
      ],
      "Origin": [
        "https://www.chemmyfashion.com"
      ],
      "X-Forwarded-Proto": [
        "https"
      ],
      "Content-Length": [
        "68"
      ],
      "Cdn-Loop": [
        "cloudflare"
      ],
      "Cf-Connecting-Ip": [
        "121.6.238.133"
      ],
      "Sec-Ch-Ua": [
        "\"Chromium\";v=\"116\", \"Not)A;Brand\";v=\"24\", \"Google Chrome\";v=\"116\""
      ],
      "Sec-Fetch-Mode": [
        "cors"
      ],
      "X-Forwarded-For": [
        "108.162.226.219"
      ],
      "X-Forwarded-Host": [
        "www.chemmyfashion.com"
      ],
      "Accept-Language": [
        "en-US,en;q=0.9,ja;q=0.8"
      ],
      "Authorization": [],
      "Sec-Ch-Ua-Platform": [
        "\"macOS\""
      ],
      "Sec-Fetch-Site": [
        "same-origin"
      ],
      "Accept": [
        "application/json, text/plain, */*"
      ],
      "Cf-Ray": [
        "800d169dcaf744b5-SIN"
      ]
    }
  },
  "user_id": "",
  "duration": 0.060187539,
  "size": 17,
  "status": 200,
  "resp_headers": {
    "Access-Control-Expose-Headers": [
      "*"
    ],
    "Etag": [
      "W/\"11-l8wg2b6ZqrDsZYSOZdfjskF4jXM\""
    ],
    "Access-Control-Allow-Origin": [
      "https://www.chemmyfashion.com"
    ],
    "Content-Length": [
      "17"
    ],
    "X-Powered-By": [
      "Express"
    ],
    "Access-Control-Allow-Credentials": [
      "true"
    ],
    "Server": [
      "Caddy"
    ],
    "Content-Type": [
      "application/json; charset=utf-8"
    ],
    "Date": [
      "Sun, 03 Sep 2023 09:50:25 GMT"
    ]
  }
}


3. Caddy version:

I am running caddy on docker compose
version is caddy:2.4.6

4. How I installed and ran Caddy:

I am using docker and docker-compose to install and run the program.

a. System environment:

OS: Linux server
Docker version: 3

b. Command:

docker-compose -f docker-compose.yml up

c. Service/unit/compose file:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

d. My complete Caddy config:

1 Main Caddy Server
2 Frontend applications run inside the Caddy server

My main caddy server Caddyfile configure like this


(cors) {
        @cors_preflight{args.0} method OPTIONS
        @cors{args.0} header Origin {args.0}

        handle @cors_preflight{args.0} {
                header {
                        Access-Control-Allow-Origin "{args.0}"
                        Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
                        Access-Control-Allow-Headers *
                        Access-Control-Max-Age "3600"
                        defer
                }
                respond "" 204
        }

        handle @cors{args.0} {
                header {
                        Access-Control-Allow-Origin "{args.0}"
                        Access-Control-Expose-Headers *
                        defer
                }
        }
}

www.chemmyfashion.com:443 {
    log {
        output file /var/log/caddy/chemmyfashion-vp-frontend.log
        format json
    }

    tls treblesolution@gmail.com
    
    import cors https://www.chemmyfashion.com
    reverse_proxy chemmy-fashion-vp-frontend:80
}

And frontend application Caddyfile configured like this


(cors) {
        @cors_preflight{args.0} method OPTIONS
        @cors{args.0} header Origin {args.0}

        handle @cors_preflight{args.0} {
                header {
                        Access-Control-Allow-Origin "{args.0}"
                        Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
                        Access-Control-Allow-Headers *
                        Access-Control-Max-Age "3600"
                        defer
                }
                respond "" 204
        }

        handle @cors{args.0} {
                header {
                        Access-Control-Allow-Origin "{args.0}"
                        Access-Control-Expose-Headers *
                        defer
                }
        }
}

:80 {
    log {
        output file /var/log/caddy/frontend.log
        format json
    }
    tls treblesolution@gmail.com
    import cors https://www.chemmyfashion.com
    root * /srv
    route {
        reverse_proxy /api* chemmy-fashion-vp-backend:5300
        try_files {path} {path}/ /index.html
        file_server
    }
}

5. Links to relevant resources:

My previous question if in case you need to refer my whole caddy server configuration

If you can goto until payment page and click the payhere button in browser console you can see the issue.

One more thing I need to double check with you is this the optimum CORS enable way because this is way i got when google it. and why it’s not working in my case.

Thank you

Any help ???

That’s a very old version. Please upgrade to the latest, v2.7.4.

This is saying that requests coming from www.payhere.lk are blocked because CORS doesn’t allow that domain. You’ll need to add import cors https://www.payhere.lk or whatever.

HI @francislavoie

I have upgrade to latest v2.7.4

And added import

Main caddy server Caddyfile


(cors) {

    @cors_preflight{args.0} method OPTIONS
    @cors{args.0} header Origin {args.0}

    handle @cors_preflight{args.0} {
        header {
            Access-Control-Allow-Origin "{args.0}"
            Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
            Access-Control-Allow-Headers *
            Access-Control-Max-Age "3600"
            defer
        }
        respond "" 204
    }

    handle @cors{args.0} {
        header {
            Access-Control-Allow-Origin "{args.0}"
            Access-Control-Expose-Headers *
            defer
        }
    }
}

www.chemmyfashion.com:443 {

    log {
        output file /var/log/caddy/chemmyfashion-vp-frontend.log
        format json
    }

    tls treblesolution@gmail.com
    
    import cors https://www.payhere.lk
    import cors https://www.payhere.lk/pay/checkoutJ
    import cors https://www.chemmyfashion.com
    
    reverse_proxy chemmy-fashion-vp-frontend:80
}

Frontend application Caddyfile


(cors) {

    @cors_preflight{args.0} method OPTIONS
    @cors{args.0} header Origin {args.0}

    handle @cors_preflight{args.0} {
        header {
            Access-Control-Allow-Origin "{args.0}"
            Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
            Access-Control-Allow-Headers *
            Access-Control-Max-Age "3600"
            defer
        }
        respond "" 204
    }

    handle @cors{args.0} {
        header {
            Access-Control-Allow-Origin "{args.0}"
            Access-Control-Expose-Headers *
            defer
        }
    }
}

:80 {

    log {
        output file /var/log/caddy/frontend.log
        format json
    }

    tls treblesolution@gmail.com

    import cors https://www.payhere.lk
    import cors https://www.payhere.lk/pay/checkoutJ
    import cors https://www.chemmyfashion.com

    root * /srv

    route {
        reverse_proxy /api* chemmy-fashion-vp-backend:5300
        try_files {path} {path}/ /index.html
        file_server
    }
}

But still CORS error is there


payhere.js:1 Access to XMLHttpRequest at 'https://www.payhere.lk/pay/checkoutJ' from origin 'https://www.chemmyfashion.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
payhere.js:1 POST https://www.payhere.lk/pay/checkoutJ net::ERR_FAILED 500

Main Caddy server logs


{
  "level": "info",
  "ts": 1694156006.533819,
  "logger": "http.log.access.log3",
  "msg": "handled request",
  "request": {
    "remote_ip": "172.70.188.52",
    "remote_port": "42112",
    "client_ip": "172.70.188.52",
    "proto": "HTTP/2.0",
    "method": "POST",
    "host": "www.chemmyfashion.com",
    "uri": "/api/orders/validate/productAvailabilityAndUpdateStockCount",
    "headers": {
      "Cf-Visitor": [
        "{\"scheme\":\"https\"}"
      ],
      "Sec-Ch-Ua-Mobile": [
        "?0"
      ],
      "Authorization": [],
      "User-Agent": [
        "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
      ],
      "Sec-Ch-Ua-Platform": [
        "\"macOS\""
      ],
      "Sec-Fetch-Mode": [
        "cors"
      ],
      "Cf-Ipcountry": [
        "SG"
      ],
      "Cf-Ray": [
        "8035463fd9d16bf3-SIN"
      ],
      "Referer": [
        "https://www.chemmyfashion.com/order/7655af3a-86c4-4fac-a8c4-7f4d02d749bc"
      ],
      "Accept-Language": [
        "en-US,en;q=0.9,ja;q=0.8"
      ],
      "Sec-Ch-Ua": [
        "\"Chromium\";v=\"116\", \"Not)A;Brand\";v=\"24\", \"Google Chrome\";v=\"116\""
      ],
      "Content-Type": [
        "application/json"
      ],
      "Sec-Fetch-Site": [
        "same-origin"
      ],
      "Cf-Connecting-Ip": [
        "121.6.238.133"
      ],
      "Content-Length": [
        "68"
      ],
      "Accept": [
        "application/json, text/plain, */*"
      ],
      "Origin": [
        "https://www.chemmyfashion.com"
      ],
      "Sec-Fetch-Dest": [
        "empty"
      ],
      "Cdn-Loop": [
        "cloudflare"
      ],
      "Accept-Encoding": [
        "gzip, br"
      ],
      "X-Forwarded-Proto": [
        "https"
      ],
      "X-Forwarded-For": [
        "121.6.238.133"
      ],
      "Priority": [
        "u=1, i"
      ]
    },
    "tls": {
      "resumed": false,
      "version": 772,
      "cipher_suite": 4865,
      "proto": "h2",
      "server_name": "www.chemmyfashion.com"
    }
  },
  "bytes_read": 68,
  "user_id": "",
  "duration": 0.054625753,
  "size": 17,
  "status": 200,
  "resp_headers": {
    "Server": [
      "Caddy",
      "Caddy"
    ],
    "Alt-Svc": [
      "h3=\":443\"; ma=2592000"
    ],
    "Date": [
      "Fri, 08 Sep 2023 06:53:26 GMT"
    ],
    "Etag": [
      "W/\"11-l8wg2b6ZqrDsZYSOZdfjskF4jXM\""
    ],
    "X-Powered-By": [
      "Express"
    ],
    "Access-Control-Allow-Origin": [
      "https://www.chemmyfashion.com"
    ],
    "Access-Control-Expose-Headers": [
      "*"
    ],
    "Content-Length": [
      "17"
    ],
    "Content-Type": [
      "application/json; charset=utf-8"
    ],
    "Access-Control-Allow-Credentials": [
      "true"
    ]
  }
}






{
  "level": "error",
  "ts": 1694156006.7010014,
  "logger": "http.log.access.log3",
  "msg": "handled request",
  "request": {
    "remote_ip": "172.70.188.52",
    "remote_port": "42112",
    "client_ip": "172.70.188.52",
    "proto": "HTTP/2.0",
    "method": "PUT",
    "host": "www.chemmyfashion.com",
    "uri": "/api/orders/7655af3a-86c4-4fac-a8c4-7f4d02d749bc/pay",
    "headers": {
      "Sec-Fetch-Site": [
        "same-origin"
      ],
      "Sec-Fetch-Mode": [
        "cors"
      ],
      "Cf-Connecting-Ip": [
        "121.6.238.133"
      ],
      "Content-Type": [
        "application/json"
      ],
      "Sec-Ch-Ua-Mobile": [
        "?0"
      ],
      "Authorization": [],
      "Referer": [
        "https://www.chemmyfashion.com/order/7655af3a-86c4-4fac-a8c4-7f4d02d749bc"
      ],
      "Priority": [
        "u=1, i"
      ],
      "Cf-Ipcountry": [
        "SG"
      ],
      "Cf-Ray": [
        "803546415bb06bf3-SIN"
      ],
      "Cf-Visitor": [
        "{\"scheme\":\"https\"}"
      ],
      "Sec-Fetch-Dest": [
        "empty"
      ],
      "Accept": [
        "application/json, text/plain, */*"
      ],
      "User-Agent": [
        "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
      ],
      "Cdn-Loop": [
        "cloudflare"
      ],
      "Accept-Encoding": [
        "gzip, br"
      ],
      "X-Forwarded-For": [
        "121.6.238.133"
      ],
      "Content-Length": [
        "96"
      ],
      "X-Forwarded-Proto": [
        "https"
      ],
      "Sec-Ch-Ua": [
        "\"Chromium\";v=\"116\", \"Not)A;Brand\";v=\"24\", \"Google Chrome\";v=\"116\""
      ],
      "Sec-Ch-Ua-Platform": [
        "\"macOS\""
      ],
      "Origin": [
        "https://www.chemmyfashion.com"
      ],
      "Accept-Language": [
        "en-US,en;q=0.9,ja;q=0.8"
      ]
    },
    "tls": {
      "resumed": false,
      "version": 772,
      "cipher_suite": 4865,
      "proto": "h2",
      "server_name": "www.chemmyfashion.com"
    }
  },
  "bytes_read": 96,
  "user_id": "",
  "duration": 0.055101228,
  "size": 29,
  "status": 404,
  "resp_headers": {
    "Date": [
      "Fri, 08 Sep 2023 06:53:26 GMT"
    ],
    "Etag": [
      "W/\"1d-wAEMKKKZFInTytphxMzWlRoj1ew\""
    ],
    "Access-Control-Allow-Origin": [
      "https://www.chemmyfashion.com"
    ],
    "Access-Control-Expose-Headers": [
      "*"
    ],
    "Content-Length": [
      "29"
    ],
    "Alt-Svc": [
      "h3=\":443\"; ma=2592000"
    ],
    "Content-Type": [
      "application/json; charset=utf-8"
    ],
    "Access-Control-Allow-Credentials": [
      "true"
    ],
    "Server": [
      "Caddy",
      "Caddy"
    ],
    "X-Powered-By": [
      "Express"
    ]
  }
}

Frontend Caddy server logs


{
  "level": "info",
  "ts": 1694156006.5331914,
  "logger": "http.log.access.log0",
  "msg": "handled request",
  "request": {
    "remote_ip": "172.18.0.2",
    "remote_port": "53264",
    "client_ip": "172.18.0.2",
    "proto": "HTTP/1.1",
    "method": "POST",
    "host": "www.chemmyfashion.com",
    "uri": "/api/orders/validate/productAvailabilityAndUpdateStockCount",
    "headers": {
      "Content-Length": [
        "68"
      ],
      "Cdn-Loop": [
        "cloudflare"
      ],
      "Sec-Fetch-Dest": [
        "empty"
      ],
      "Referer": [
        "https://www.chemmyfashion.com/order/7655af3a-86c4-4fac-a8c4-7f4d02d749bc"
      ],
      "X-Forwarded-For": [
        "172.70.188.52"
      ],
      "Cf-Connecting-Ip": [
        "121.6.238.133"
      ],
      "Sec-Fetch-Mode": [
        "cors"
      ],
      "Authorization": [],
      "X-Forwarded-Host": [
        "www.chemmyfashion.com"
      ],
      "User-Agent": [
        "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
      ],
      "Accept-Language": [
        "en-US,en;q=0.9,ja;q=0.8"
      ],
      "Content-Type": [
        "application/json"
      ],
      "Origin": [
        "https://www.chemmyfashion.com"
      ],
      "Sec-Ch-Ua-Platform": [
        "\"macOS\""
      ],
      "Sec-Fetch-Site": [
        "same-origin"
      ],
      "Accept": [
        "application/json, text/plain, */*"
      ],
      "Cf-Ipcountry": [
        "SG"
      ],
      "Cf-Visitor": [
        "{\"scheme\":\"https\"}"
      ],
      "Priority": [
        "u=1, i"
      ],
      "X-Forwarded-Proto": [
        "https"
      ],
      "Accept-Encoding": [
        "gzip, br"
      ],
      "Cf-Ray": [
        "8035463fd9d16bf3-SIN"
      ],
      "Sec-Ch-Ua": [
        "\"Chromium\";v=\"116\", \"Not)A;Brand\";v=\"24\", \"Google Chrome\";v=\"116\""
      ],
      "Sec-Ch-Ua-Mobile": [
        "?0"
      ]
    }
  },
  "bytes_read": 68,
  "user_id": "",
  "duration": 0.053555821,
  "size": 17,
  "status": 200,
  "resp_headers": {
    "X-Powered-By": [
      "Express"
    ],
    "Content-Length": [
      "17"
    ],
    "Etag": [
      "W/\"11-l8wg2b6ZqrDsZYSOZdfjskF4jXM\""
    ],
    "Date": [
      "Fri, 08 Sep 2023 06:53:26 GMT"
    ],
    "Access-Control-Allow-Origin": [
      "https://www.chemmyfashion.com"
    ],
    "Server": [
      "Caddy"
    ],
    "Access-Control-Allow-Credentials": [
      "true"
    ],
    "Content-Type": [
      "application/json; charset=utf-8"
    ],
    "Access-Control-Expose-Headers": [
      "*"
    ]
  }
}




{
  "level": "error",
  "ts": 1694156006.7005908,
  "logger": "http.log.access.log0",
  "msg": "handled request",
  "request": {
    "remote_ip": "172.18.0.2",
    "remote_port": "53264",
    "client_ip": "172.18.0.2",
    "proto": "HTTP/1.1",
    "method": "PUT",
    "host": "www.chemmyfashion.com",
    "uri": "/api/orders/7655af3a-86c4-4fac-a8c4-7f4d02d749bc/pay",
    "headers": {
      "Cf-Ray": [
        "803546415bb06bf3-SIN"
      ],
      "Origin": [
        "https://www.chemmyfashion.com"
      ],
      "Cf-Visitor": [
        "{\"scheme\":\"https\"}"
      ],
      "Sec-Ch-Ua-Mobile": [
        "?0"
      ],
      "Accept": [
        "application/json, text/plain, */*"
      ],
      "Authorization": [],
      "Accept-Language": [
        "en-US,en;q=0.9,ja;q=0.8"
      ],
      "Sec-Fetch-Dest": [
        "empty"
      ],
      "Accept-Encoding": [
        "gzip, br"
      ],
      "Priority": [
        "u=1, i"
      ],
      "Sec-Fetch-Mode": [
        "cors"
      ],
      "X-Forwarded-Proto": [
        "https"
      ],
      "Content-Length": [
        "96"
      ],
      "Sec-Ch-Ua": [
        "\"Chromium\";v=\"116\", \"Not)A;Brand\";v=\"24\", \"Google Chrome\";v=\"116\""
      ],
      "Sec-Ch-Ua-Platform": [
        "\"macOS\""
      ],
      "User-Agent": [
        "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
      ],
      "Cf-Connecting-Ip": [
        "121.6.238.133"
      ],
      "X-Forwarded-For": [
        "172.70.188.52"
      ],
      "X-Forwarded-Host": [
        "www.chemmyfashion.com"
      ],
      "Cdn-Loop": [
        "cloudflare"
      ],
      "Cf-Ipcountry": [
        "SG"
      ],
      "Content-Type": [
        "application/json"
      ],
      "Referer": [
        "https://www.chemmyfashion.com/order/7655af3a-86c4-4fac-a8c4-7f4d02d749bc"
      ],
      "Sec-Fetch-Site": [
        "same-origin"
      ]
    }
  },
  "bytes_read": 96,
  "user_id": "",
  "duration": 0.054243594,
  "size": 29,
  "status": 404,
  "resp_headers": {
    "Etag": [
      "W/\"1d-wAEMKKKZFInTytphxMzWlRoj1ew\""
    ],
    "Access-Control-Allow-Credentials": [
      "true"
    ],
    "Content-Type": [
      "application/json; charset=utf-8"
    ],
    "Date": [
      "Fri, 08 Sep 2023 06:53:26 GMT"
    ],
    "X-Powered-By": [
      "Express"
    ],
    "Access-Control-Expose-Headers": [
      "*"
    ],
    "Content-Length": [
      "29"
    ],
    "Access-Control-Allow-Origin": [
      "https://www.chemmyfashion.com"
    ],
    "Server": [
      "Caddy"
    ]
  }
}

Thank you

Your Caddy logs are showing requests to www.chemmyfashion.com, not to www.payhere.lk.

This is saying that requests to www.payhere.lk are not allowed when you make the request on www.chemmyfashion.com. The Access-Control-Allow-Origin header needs to be configured on whatever server is serving www.payhere.lk, not on your server with www.chemmyfashion.com.

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