Fix static file endpoints after Astro v4 upgrade
Yesterday I upgraded to Astro v4 without any issues, but this morning I noticed that my RSS feed was broken.
I have two static file endpoints that generate a file at build time, one for RSS and the other for a webfinger. Both of these had two issues highlighted after the upgrade:
- The files did not export a
GETfunction - The files did not return a
ResponseorPromise<Response>
The first issue was resolved by capitalizing the previously-valid get function
to GET.
The second issue required an update to the @astrojs/rss dependency which now
returns a Promise<Response>. The webfinger endpoint is custom, but all I
needed to do was wrap my return value with a Response object:
// Before
return { body: JSON.stringify(data, null, 2) };
// After
return new Response(JSON.stringify(data, null, 2));
The webfinger issue is easy to miss (and nonconsequential), but I should have verified that the RSS feed was working before shipping the upgrade. Lessons learned!