mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
fix: forward headers during requests where needed
this is mainly just so any ip headers like cf-connecting-ip are forwarded for rate limiting
This commit is contained in:
@@ -4,7 +4,7 @@ import { apiUrl } from '$lib/server/api';
|
||||
import { getServerToken, clearServerTokens, roles, getUserFromToken } from '$lib/utils/auth';
|
||||
import type { Report } from '$lib/types/report';
|
||||
|
||||
export const load: PageServerLoad = async ({ fetch, cookies, params, url }) => {
|
||||
export const load: PageServerLoad = async ({ fetch, cookies, params, url, request }) => {
|
||||
const token = getServerToken(cookies);
|
||||
if (!token) throw error(401, 'Login required');
|
||||
|
||||
@@ -14,9 +14,11 @@ export const load: PageServerLoad = async ({ fetch, cookies, params, url }) => {
|
||||
throw error(401, 'Invalid token');
|
||||
}
|
||||
const canEdit = (user.roles & roles.Admin) !== 0 || (user.roles & roles.Moderator) !== 0;
|
||||
const headers = new Headers(request.headers);
|
||||
headers.set('Authorization', `Bearer ${token}`);
|
||||
|
||||
const res = await fetch(`${apiUrl}/api/report/${params.reportId}`, {
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
headers: headers
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
|
||||
Reference in New Issue
Block a user