File size: 1,081 Bytes
3325049
 
7bd88f8
 
 
3325049
7bd88f8
3325049
7bd88f8
3325049
 
7bd88f8
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
---
title: Pi Web Preview
emoji: 🪟
colorFrom: gray
colorTo: gray
sdk: docker
app_port: 7860
pinned: false
short_description: Direct previews of dev servers for Pi Web
---

# Pi Web previews

The origin that [Pi Web](https://mike0021-pi-web.hf.space) frames to show a user's own dev
server (for example a Vite app on their machine's port 5173) natively, on a different site from
Pi Web so app code can never act with the user's Pi Web session.

There is nothing to open here directly: Pi Web asks its gateway for a capability link
(`/__pv/<cap>/`), this Space keeps it in a partitioned, HttpOnly cookie and relays every request
to the gateway, which checks the capability and forwards to that user's machine only.
Plain HTTP and server-sent events stream both ways; WebSocket upgrades (hot module reload
sockets) are not supported. Only Pi Web may frame these pages (`frame-ancestors`).

Configuration: secret `PREVIEW_RELAY_SECRET` (shared with the gateway Space), optional variables
`PREVIEW_GATEWAY` (default `https://mike0021-pi-web.hf.space`) and `PREVIEW_FRAME_ANCESTORS`.