Files
supabase/apps
Pamela Chia 43bacd2f70 fix(www): use service role key for LWX edge function storage uploads (#46411)
## Summary

The three LWX edge functions consume `MISC_USE_ANON_KEY` while their
inline comments claim "SERVICE ROLE KEY": a copy-paste bug. This PR
swaps them to `MISC_USE_SERVICE_ROLE_KEY`, matching `lw11-og` (the
reference implementation that already uses the service role pattern
correctly). The secret is already configured on the project. Service
role bypasses RLS, so uploads succeed regardless of bucket policy and
the key is never exposed (edge functions are server-side).

## Changes

- `lwx-ticket/handler.tsx`: swap storage client to use
`MISC_USE_SERVICE_ROLE_KEY`
- `lwx-og/handler.tsx`: swap storage client to use
`MISC_USE_SERVICE_ROLE_KEY`
- `lwx-ticket-og/handler.tsx`: swap storage client to use
`MISC_USE_SERVICE_ROLE_KEY`

## Testing (Vercel preview)

1. Hit an LWX ticket share URL with a Twitterbot UA: `curl -A
'Twitterbot/1.0' '<preview>/launch-week/x/tickets/<username>'` — expect
HTML with OG meta tags, no edge function error.
2. Confirm the storage object got upserted at
`images/lwx/og/<type>/<username>.png` on `obuldanrptloktxcffvn`.
3. Confirm `MISC_USE_SERVICE_ROLE_KEY` is set as an edge function secret
on the project (it already powers `lw11-og`, so it should be).

### Follow-up (separate, manual)

After merge and deploy, the storage policy on the `images` bucket needs
tightening via the dashboard (no migration setup exists for this
project): revoke `INSERT`/`UPDATE`/`DELETE` policies that grant `anon`,
keep `SELECT` public. All legitimate writers (dashboard team uploads,
LWX/LW11 edge functions) use service role and will continue to work.

## Linear

- fixes GROWTH-882


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
* Updated backend authentication configuration for image generation and
ticket-related operations.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46411?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-27 15:36:24 +08:00
..
2026-05-27 08:40:17 +02:00