Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules
.env
.env.*
!.env.example
/.vercel
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
- The `prepare` script (`svelte-kit sync`) runs automatically during `npm install`. If you see import errors for `$app/*` modules, re-run `npm install`.
- The dev server uses Vite's default port **5173**. Pass `--host 0.0.0.0` to expose it outside localhost: `npm run dev -- --host 0.0.0.0`.
- Requires **Node.js >= 24** (`engines` field in `package.json`). Use `nvm use 24` if multiple versions are installed.
- Preview functionality depends on the external CORS proxy `api.codetabs.com`. If previews fail to load, this third-party service may be down.
- Preview functionality uses the internal `/api/proxy` endpoint. Configure `PROXY_ALLOWED_ORIGINS` with deployment origins (comma separated) to restrict CORS.
- `svelte-preprocess` deprecation warnings about "defaults" are expected and harmless.
- The `package-lock.json` uses npm; do not mix with other package managers.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ npm i
npm run dev -- --open
```

## Proxy Configuration

Preview fetching now uses the first-party SvelteKit endpoint at `/api/proxy` (instead of `api.codetabs.com`), which requires a server adapter such as Vercel.

To lock down CORS for your deployment domain(s), configure:

```sh
PROXY_ALLOWED_ORIGINS=https://static-preview.vercel.app,http://localhost:5173
```

Security constraints in `/api/proxy`:

- only proxies `https://raw.githubusercontent.com/...` URLs
- only proxies GitLab `https://gitlab.com/.../-/raw/...` URLs
- rejects non-HTTPS targets, query strings, and path traversal
- allows requests only from configured origins (checks `Origin` then `Referer`)
- enforces a max upstream payload size of 5 MiB

## Testing

We use [Jest](https://jestjs.io/) for unit testing. Only URL parsing is tested to prevent regressions.
Expand Down
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default [
'.DS_Store',
'node_modules/**',
'build/**',
'.vercel/**',
'.svelte-kit/**',
'package/**',
'.env',
Expand Down
Loading
Loading