Skip to content

Refactor /api/logo to use HTTP redirects for direct HTML <img> embedding #1094

Description

@anujarora0502

Describe the enhancement

Currently, the /api/logo endpoint returns a 200 OK status with a Content-Type: application/json payload containing the signed CloudFront URL for the requested logo.
Example Current Response:

// GET /api/logo?key=google.com&API_KEY=...
{
  "statusCode": 200,
  "data": "https://d30qwik574etgt.cloudfront.net/png/GOOGLE.png?..."
}

While this works for client-side JavaScript applications that parse the JSON and then mount the image, it prevents users from using the API directly in HTML. When a browser encounters <img src="https://api-stage.openlogo.fyi/api/logo...">, it expects a binary image file or a redirect to one. Instead, it receives JSON text, fails to parse it as an image, and renders a broken image icon.

Expected Behavior

Developers should be able to drop the API URL directly into standard HTML tags, Markdown files, or email templates like this:

<img src="https://api-stage.openlogo.fyi/api/logo?key=google.com&API_KEY=YOUR_KEY" alt="Google Logo" />

Task / Proposed Solution

Update the API endpoint controller so that instead of returning a JSON response, it issues an HTTP Redirect to the generated CDN URL.
Implementation Steps:

  1. Locate the endpoint controller handling /api/logo.
  2. Instead of returning the URL in a JSON payload (res.status(200).json(...)), update the response to send an HTTP 302 (Found) or HTTP 307 (Temporary Redirect) status code.
  3. Set the Location header of the response to the generated CloudFront CDN URL.
    (Note: If using Next.js/Vercel, you can typically use res.redirect(307, cdnUrl)).
  4. Ensure error states (e.g., missing API key, rate limits, logo not found) still return appropriate standard JSON/text HTTP error codes (400, 401, 404, 429).

Acceptance Criteria

  • A GET request to /api/logo with valid parameters returns an HTTP 302 or 307 status.
  • The response includes a Location header pointing to the valid d30qwik574etgt.cloudfront.net URL.
  • The API URL can be placed directly into an <img src="..."> tag in a plain HTML file and successfully renders the image in a browser.

Why should this enhancement be implemented? Add additional informaiton.

No response

Confirmation

  • I have searched for similar issues before creating this one.
  • I have provided all the necessary information to understand this documentation issue.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions