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