Include credentials on client-side dashboard API requests
This commit is contained in:
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user