Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DELETE endpoints do not include ‘Access-Control-Allow-Origin’ in the header which causes web browsers to report a CORS error #2261

Open
mwoolweaver opened this issue Feb 23, 2025 · 5 comments

Comments

@mwoolweaver
Copy link

mwoolweaver commented Feb 23, 2025

Versions

Core
Version is v6.0.4-1-ga7e414ac (Latest: null)
Branch is development
Hash is a7e414a (Latest: a7e414a)
Web
Version is v6.0.1-10-gec8beaf5 (Latest: null)
Branch is development
Hash is ec8beaf5 (Latest: ec8beaf5)
FTL
Version is vDev-39a852e (Latest: null)
Branch is development
Hash is 39a852e (Latest: 39a852e)

Platform

  • OS and version: Ubuntu 24.04.2
  • Platform: Raspberry Pi 4

Expected behavior

Access-Control-Allow-Origin: * to be in the header like it is with other endpoints

Actual behavior / bug

Access-Control-Allow-Origin: * is missing and seems to cause Firefox and Chrome to report a CORS error

Steps to reproduce

Steps to reproduce the behavior:

https://gist.github.com/mwoolweaver/f5fe7a58f38cfe68e05b7b5e491e65fc

simple website to allow quickly disabling pihole via bookmark

  1. download the file locally (not on Pi-hole)

  2. Open in firefox or chrome and fill in the boxes with relevant info and open the inspector before clicking submit

  3. click submit and watch the DELETE request show a CORS error

  4. now host that same file on the Pi-hole device, repeat steps 2 & 3

  5. now you will see the 204 response that's expected without the CORS error

Debug Token

Screenshots

Additional context

Add any other context about the problem here.

@mwoolweaver
Copy link
Author

mwoolweaver commented Feb 23, 2025

i know that additional headers can be included but i don't understand what causes the DELETE to fail when not hosted on Pi-hole device and all the other requests are successful

@mwoolweaver
Copy link
Author

mwoolweaver commented Feb 23, 2025

Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: *
Access-Control-Allow-Methods: *

these are included in the response of every other endpoint that's not a DELETE endpoint from what i can see.

@mwoolweaver mwoolweaver changed the title when an api endpoint returns 204 code it does not include the CORS header ‘Access-Control-Allow-Origin’ which cause web browser to report a 401 when an api endpoint returns 204 code it does not include in the header ‘Access-Control-Allow-Origin’ which cause web browser to report a CORS error Feb 23, 2025
@mwoolweaver mwoolweaver changed the title when an api endpoint returns 204 code it does not include in the header ‘Access-Control-Allow-Origin’ which cause web browser to report a CORS error DELETE endpoints do not include ‘Access-Control-Allow-Origin’ in the header which causes web browsers to report a CORS error Feb 23, 2025
@DL6ER
Copy link
Member

DL6ER commented Feb 23, 2025

Access-Control-Allow-Origin: * to be in the header like it is with other endpoints

Is it?

From another machine:

$ curl -Ik https://pi.hole/admin/login
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, must-revalidate, private, max-age=0
Expires: 0
Pragma: no-cache
Content-Security-Policy: default-src 'self' 'unsafe-inline';
X-Frame-Options: DENY
X-XSS-Protection: 0
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin
Content-Type: text/html; charset=utf-8
Date: Sun, 23 Feb 2025 18:47:38 GMT
Connection: close

On the Pi-hole itself:

$ curl -Ik https://localhost/admin/login
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, must-revalidate, private, max-age=0
Expires: 0
Pragma: no-cache
Content-Security-Policy: default-src 'self' 'unsafe-inline';
X-Frame-Options: DENY
X-XSS-Protection: 0
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin
Content-Type: text/html; charset=utf-8
Date: Sun, 23 Feb 2025 18:48:32 GMT
Connection: close

I don't see Access-Control-Allow-Origin or any of its friends here.

@mwoolweaver
Copy link
Author

mwoolweaver commented Feb 23, 2025

I wonder where Firefox and Chrome are getting them from?

this is Firefox
Image

this is Chrome
Image

if this is a browser issue feel free to close.

@DL6ER
Copy link
Member

DL6ER commented Mar 1, 2025

I am undecided concerning the Access-Control-Allow-Origin (and friends) headers. How should they look like on Pi-hole? Should we set them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants