18 lines
612 B
TypeScript
18 lines
612 B
TypeScript
export default defineEventHandler(async (event) => {
|
|
const user = process.env.NUXT_PRIVATE_SUPERUSER_USER;
|
|
const password = process.env.NUXT_PRIVATE_SUPERUSER_PASSWORD;
|
|
if (user == null || password == null)
|
|
{
|
|
console.error("Username or password is null.");
|
|
throw Error();
|
|
}
|
|
|
|
event.headers.delete("origin");
|
|
event.headers.set("authorization", "Basic " + Buffer.from(user + ':' + password).toString('base64'))
|
|
|
|
return proxyRequest(event, process.env.NUXT_PUBLIC_BASE_URL + event.path, {
|
|
fetchOptions: {
|
|
headers: event.headers
|
|
}
|
|
});
|
|
}) |