Ravi Sir's Cards › AWS
Why return 302 instead of 200 with the long URL?
This interview card answers: Why return 302 instead of 200 with the long URL? Browsers automatically follow the Location header. That is what users expect from a short link. A JSON 200 forces every client (browser, WhatsApp preview, curl scripts) to special-case your API. Lambda returns statusCode 302 and headers Location = longUrl from DynamoDB GetItem.
Read card text
What this card says
What it is
Browsers automatically follow the Location header. That is what users expect from a short link.
Why it matters
A JSON 200 forces every client (browser, WhatsApp preview, curl scripts) to special-case your API.
How / example
Lambda returns statusCode 302 and headers Location = longUrl from DynamoDB GetItem.