28 lines
No EOL
684 B
TypeScript
28 lines
No EOL
684 B
TypeScript
import type { APIRoute } from 'astro';
|
|
|
|
export const POST: APIRoute = async ({ request, url }) => {
|
|
if (request.method === 'OPTIONS') {
|
|
return new Response(null, {
|
|
status: 204,
|
|
headers: {
|
|
'Access-Control-Allow-Origin': '*',
|
|
'Access-Control-Allow-Methods': 'POST, OPTIONS',
|
|
'Access-Control-Allow-Headers': 'Content-Type',
|
|
}
|
|
});
|
|
}
|
|
|
|
const params = Object.fromEntries(url.searchParams.entries());
|
|
|
|
return new Response(JSON.stringify({
|
|
method: 'POST',
|
|
params,
|
|
url: request.url,
|
|
}), {
|
|
status: 200,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Access-Control-Allow-Origin': '*',
|
|
}
|
|
});
|
|
}; |