I am attempting to create a Vercel deployment of a NextJS v14 project, using the “app router” method of internal routing. I created a few pages that handle responses directly, which are attempting to fulfil the requirements to be an ActivityPub server. Part of that requires that the Content-Type
header for JSON-style responses to be set to application/ld+json; profile="https://www.w3.org/ns/activitystreams"
.
Using a sample script of api/instance-actor/route.ts
export async function GET(request: NextRequest) {
return new Response(JSON.stringify({ hello: 'world' }), {
headers: {
'Content-Type':
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
},
})
}
that returns a proper response when I test with Postman against a local NextJS dev build.
However, when it gets deployed to Vercel, even with the Vercel toolbar turned off, there appears to be some security screen served up instead of the actual content. Using Postman to get at the plain response, when fetching api/instance-actor/
, Vercel is returning a text/html
document with a title of “Authentication Required”.
This appears to be a security screen that works well in a browser to pass the visitor along, but not for a machine-to-machine call.
How can I designate specific routes within my NextJS application to be intended for machine-to-machine communication, and therefore needs CORS and other settings configured to not require a browser-style challenge to be passed?