35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { NextResponse } from 'next/server';
|
|
|
|
/**
|
|
* This route is deprecated. It redirects to the new courrier API endpoint.
|
|
* @deprecated Use the /api/courrier/send endpoint instead
|
|
*/
|
|
export async function POST(request: Request) {
|
|
console.warn('Deprecated: /api/mail/send route is being used. Update your code to use /api/courrier/send instead.');
|
|
|
|
try {
|
|
// Clone the request body
|
|
const body = await request.json();
|
|
|
|
// Make a new request to the courrier API
|
|
const newRequest = new Request(new URL('/api/courrier/send', request.url).toString(), {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify(body)
|
|
});
|
|
|
|
// Forward the request
|
|
const response = await fetch(newRequest);
|
|
const data = await response.json();
|
|
|
|
return NextResponse.json(data, { status: response.status });
|
|
} catch (error) {
|
|
console.error('Error forwarding to courrier/send:', error);
|
|
return NextResponse.json(
|
|
{ error: 'Failed to send email' },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|