Include credentials on client-side dashboard API requests

This commit is contained in:
2026-05-11 15:02:28 +07:00
parent 9864d3f033
commit b759077a45
8 changed files with 29 additions and 2 deletions

View File

@ -83,6 +83,7 @@ export function CampaignDetailActions({ campaign }: Props) {
setIsDuplicating(true);
const response = await fetch(`/api/campaigns/${campaign.id}/duplicate`, {
method: 'POST',
credentials: 'include',
});
const payload = await readPayload(response);
router.push(`/dashboard/campaigns/${payload.id}`);
@ -107,6 +108,7 @@ export function CampaignDetailActions({ campaign }: Props) {
setIsSendingNow(true);
const response = await fetch(`/api/campaigns/${campaign.id}/send`, {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ mode: 'now' }),
});
@ -133,6 +135,7 @@ export function CampaignDetailActions({ campaign }: Props) {
setIsScheduling(true);
const response = await fetch(`/api/campaigns/${campaign.id}/send`, {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ mode: 'scheduled', scheduledAt: new Date(scheduledAt).toISOString() }),
});
@ -180,7 +183,10 @@ export function CampaignDetailActions({ campaign }: Props) {
try {
setMessage(null);
setIsDeleting(true);
const response = await fetch(`/api/campaigns/${campaign.id}`, { method: 'DELETE' });
const response = await fetch(`/api/campaigns/${campaign.id}`, {
method: 'DELETE',
credentials: 'include',
});
if (!response.ok && response.status !== 204) {
await readPayload(response);
}
@ -211,6 +217,7 @@ export function CampaignDetailActions({ campaign }: Props) {
setIsSaving(true);
const response = await fetch(`/api/campaigns/${campaign.id}`, {
method: 'PATCH',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
...form,