Add basic authentication

This commit is contained in:
2026-05-02 14:59:05 +02:00
parent e1c6ea9e51
commit f1fd72520a
15 changed files with 369 additions and 66 deletions
+5 -5
View File
@@ -1,8 +1,8 @@
import { makeApiUrl } from '.';
import { fetchWithAuth } from '.';
import type { CreateForwardRuleRequest, ForwardRule } from './types/site';
export const getForwardRules = async (siteId: string): Promise<ForwardRule[]> => {
const response = await fetch(makeApiUrl(`/sites/${siteId}/forward-rules`), {
const response = await fetchWithAuth(`/sites/${siteId}/forward-rules`, {
method: 'GET',
});
if (!response.ok) {
@@ -15,7 +15,7 @@ export const createForwardRule = async (
siteId: string,
data: CreateForwardRuleRequest
): Promise<ForwardRule> => {
const response = await fetch(makeApiUrl(`/sites/${siteId}/forward-rules`), {
const response = await fetchWithAuth(`/sites/${siteId}/forward-rules`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -33,7 +33,7 @@ export const updateForwardRule = async (
ruleId: string,
data: CreateForwardRuleRequest
): Promise<ForwardRule> => {
const response = await fetch(makeApiUrl(`/sites/${siteId}/forward-rules/${ruleId}`), {
const response = await fetchWithAuth(`/sites/${siteId}/forward-rules/${ruleId}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
@@ -47,7 +47,7 @@ export const updateForwardRule = async (
};
export const deleteForwardRule = async (siteId: string, ruleId: string): Promise<void> => {
const response = await fetch(makeApiUrl(`/sites/${siteId}/forward-rules/${ruleId}`), {
const response = await fetchWithAuth(`/sites/${siteId}/forward-rules/${ruleId}`, {
method: 'DELETE',
});
if (!response.ok) {