solid-start icon indicating copy to clipboard operation
solid-start copied to clipboard

[Bug?]: API requests missing HEAD request functionality

Open paularmstrong opened this issue 1 year ago • 0 comments

Duplicates

  • [X] I have searched the existing issues

Latest version

  • [X] I have tested the latest version

Current behavior 😯

curl --head https://example.com/my/api/route.json

Always returns a 404

Expected behavior 🤔

Should return from a HEAD function if defined in the correct file, otherwise fall back on GET request (omitting the body of the response).

Steps to reproduce 🕹

Steps:

  1. Create an api file src/routes/my/api/route.json.ts
  2. Add export function HEAD = async () => new Response('', { status: 200 });
  3. (OR) Add export function GET = async () => new Response('', { status: 200 });
  4. curl --head https://example.com/my/api/route.json

Context 🔦

I'm generating OG images on my server and using a third-party service to cache and re-serve them from their CDN. This services makes HEAD requests to ensure the file exists before attempting to serve it. Since HEAD responses are giving 404s, the service will not try to serve the file.

Your environment 🌎

n/a

paularmstrong avatar Oct 22 '24 18:10 paularmstrong