You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Closestldraw#9024
In order to stop the default Google Maps embed from reading
`process.env.NEXT_PUBLIC_GC_API_KEY` inside the SDK (tldraw#9024), this PR
lets consumers pass per-embed config through `EmbedShapeUtil.configure`.
Config is keyed by embed type, so each definition only receives its own
values and no key leaks across embeds.
```ts
EmbedShapeUtil.configure({
embedConfig: { google_maps: { apiKey: '...' } },
})
```
tldraw.com now configures the embed util explicitly (reading the
vite-inlined key in app code) instead of relying on the SDK reading the
env var.
### Change type
- [x] `api`
### Test plan
1. Configure `EmbedShapeUtil` with a `google_maps` api key and paste a
Google Maps URL — the embed renders with the key.
2. Without config, the maps embed URL has no key (no env fallback in the
SDK).
- [x] Unit tests
### API changes
- Added `embedConfig` option to `EmbedShapeOptions`.
- Added `GoogleMapsEmbedConfig` and `DefaultEmbedConfig` types.
- `EmbedDefinition`/`CustomEmbedDefinition` are now generic over a
`Config`; `toEmbedUrl(url, config?)` takes an optional per-embed config.
- `getEmbedInfo`/`matchUrl` accept an optional `embedConfig` argument.
### Release notes
- Add `embedConfig` to `EmbedShapeUtil` so embeds like Google Maps can
be given an API key via `EmbedShapeUtil.configure({ embedConfig: {
google_maps: { apiKey } } })`. The default Google Maps embed no longer
reads `process.env.NEXT_PUBLIC_GC_API_KEY`.
0 commit comments