# Edge proxy

The best-SEO delivery: route `/blog/*` on your domain to the baas render
API. Crawlers see full server-rendered HTML served from *your* origin — no
JavaScript involved. Pages arrive with title, meta description, canonical
URL, and JSON-LD already in place.

Replace `PK` with your site's public key and adjust the base path if your
blog isn't mounted at `/blog`.

## Cloudflare Worker

Deploy with a route of `yourdomain.com/blog*`:

```js
const API = 'https://api.dailysmith.com';
const PUBLIC_KEY = 'PK'; // your pk_live_… key
const BASE_PATH = '/blog';

export default {
  async fetch(request) {
    const url = new URL(request.url);
    if (!url.pathname.startsWith(BASE_PATH)) {
      return fetch(request);
    }
    const upstream = new URL(`${API}/v1/render/${PUBLIC_KEY}${url.pathname}`);
    upstream.search = url.search;
    const response = await fetch(upstream, {
      headers: { 'User-Agent': request.headers.get('User-Agent') ?? 'baas-edge' },
      cf: { cacheTtl: 300, cacheEverything: true }
    });
    return new Response(response.body, {
      status: response.status,
      headers: response.headers
    });
  }
};
```

## Vercel

`vercel.json`:

```json
{
  "rewrites": [
    { "source": "/blog", "destination": "https://api.dailysmith.com/v1/render/PK/blog" },
    { "source": "/blog/:path*", "destination": "https://api.dailysmith.com/v1/render/PK/blog/:path*" }
  ]
}
```

## Netlify

`_redirects`:

```
/blog        https://api.dailysmith.com/v1/render/PK/blog        200
/blog/*      https://api.dailysmith.com/v1/render/PK/blog/:splat 200
```

## nginx

```nginx
location /blog {
    proxy_pass https://api.dailysmith.com/v1/render/PK/blog;
    proxy_set_header Host api.dailysmith.com;
    proxy_ssl_server_name on;
}
```

## Caddy

```caddy
handle_path /blog* {
    rewrite * /v1/render/PK/blog{uri}
    reverse_proxy https://api.dailysmith.com
}
```

## Notes

- The render API resolves your blog by the path as it appears on your site,
  so the same URLs work across proxy, SDK, and prerender — switch or
  combine integrations without breaking links.
- Responses carry strong ETags and CDN-friendly cache headers; your edge
  can cache them safely. Publishing a post or changing the theme changes
  the ETag.
- Styling: pages ship with a readable default and your
  [theme palette](/docs/theming). Your own stylesheet can override
  anything — the content is plain HTML under classes like `.baas-post`.

:::callout{severity=info title="Proxy + SDK together"}
Serve SSR pages through the proxy *and* include the SDK snippet in the
page shell: crawlers and first paint get static HTML, readers get instant
client-side navigation after that.
:::
