docs: update README with live deployment info and correct example commands
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
|
||||
HTTP proxy untuk Vercel Edge Runtime.
|
||||
|
||||
## Live Deployment
|
||||
|
||||
Endpoint utama: `https://proxy-bun.vercel.app/api/relay`
|
||||
|
||||
## Cara Pakai
|
||||
|
||||
### Header yang Dibutuhkan
|
||||
@@ -15,12 +19,12 @@ HTTP proxy untuk Vercel Edge Runtime.
|
||||
|
||||
```bash
|
||||
# Proxy
|
||||
curl -H "x-relay-target: https://jsonplaceholder.typicode.com/posts/1" https://vercel-relay-alpha-umber.vercel.app/
|
||||
curl -H "x-relay-target: https://jsonplaceholder.typicode.com/posts/1" https://proxy-bun.vercel.app/api/relay
|
||||
|
||||
# Proxy ke endpoint spesifik
|
||||
curl -H "x-relay-target: https://api.example.com" \
|
||||
-H "x-relay-path: /v1/users" \
|
||||
https://vercel-relay-alpha-umber.vercel.app/
|
||||
https://proxy-bun.vercel.app/api/relay
|
||||
```
|
||||
|
||||
### HTTP Methods
|
||||
@@ -50,10 +54,13 @@ HTTP 400 jika `x-relay-target` tidak ada.
|
||||
## Struktur Kode
|
||||
|
||||
```
|
||||
proxy-vercel/
|
||||
├── index.ts # Edge handler
|
||||
├── relay-utils.ts # Pure functions untuk relay logic
|
||||
└── index.test.ts # Unit tests
|
||||
proxy-bun/
|
||||
├── src/
|
||||
│ ├── app/
|
||||
│ │ └── api/relay/route.ts # Edge handler
|
||||
│ └── lib/
|
||||
│ ├── relay-utils.ts # Pure functions untuk relay logic
|
||||
│ └── relay-utils.test.ts # Unit tests
|
||||
```
|
||||
|
||||
### relay-utils.ts
|
||||
@@ -61,7 +68,7 @@ proxy-vercel/
|
||||
| Function | Deskripsi |
|
||||
|----------|-----------|
|
||||
| `normalizeTargetUrl(target, path)` | Gabung target + path, hapus trailing slash |
|
||||
| `stripRelayHeaders(headers)` | Hapus relay-specific headers |
|
||||
| `filterHeaders(headers)` | Filter relay & security headers |
|
||||
| `shouldSendBody(method)` | Cek apakah method butuh body |
|
||||
| `buildRelayRequest(req, url, headers)` | Bangun RequestInit untuk fetch |
|
||||
| `createRelayResponse(response)` | Buat Response dari fetch result |
|
||||
@@ -69,6 +76,6 @@ proxy-vercel/
|
||||
## Development
|
||||
|
||||
```bash
|
||||
bun test # Run tests
|
||||
bun run index.ts # Start local server (untuk manual testing)
|
||||
bun test # Run tests
|
||||
bun run dev # Start local Next.js server
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user