Skip to content

Commit

Permalink
fix: set response header Access-Control-Allow-Private-Network to true (
Browse files Browse the repository at this point in the history
…#159)

This is a new cors header that is required when you set the chrome flag
'Experimental Web Platform features'. We may use that flag for bluetooth
etc. This header isn't yet supported by our CORS lib etc, so this seems
to be an OK way of adding it.
  • Loading branch information
angusjfw authored Mar 15, 2024
1 parent da96f4f commit ef9f9f9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN apt-get update && \
RUN git clone https://github.com/pi-top/pi-topOS-Apt-Source.git && \
cd pi-topOS-Apt-Source && \
cp keys/* /usr/share/keyrings/ && \
cp sources/pi-top-os.list /etc/apt/sources.list.d/ && \
usr/lib/pi-top-os-apt-installer/pi-top-apt-source-manager install pi-top-os && \
apt-get update && \
rm -rf /pi-topOS-Apt-Source

Expand Down
5 changes: 5 additions & 0 deletions further_link/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ async def create_bluetooth_app() -> Optional[BluetoothServer]:
async def create_web_app():
app = web.Application()

async def set_extra_cors_headers(request, response):
response.headers["Access-Control-Allow-Private-Network"] = "true"

app.on_response_prepare.append(set_extra_cors_headers)

cors = aiohttp_cors.setup(
app,
defaults={
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
async def test_status(http_client):
response = await http_client.get(STATUS_PATH)
assert response.status == 200
assert response.headers["Access-Control-Allow-Private-Network"] == "true"
assert await response.text() == "OK"


Expand Down

0 comments on commit ef9f9f9

Please sign in to comment.