I'm having my Nextjs 13 app and another app which is a shop. Now i want to click on a product from my nextjs app which would send the cookies to my shop app and thus update the cart.
I am aware that i have to allow CORS and set "Access-Control-Allow-Origin", "your-origin.com"
and "Access-Control-Allow-Credentials", "true"
in my shop app and i did that.
This is the api code to access my shop and update the cart:
const responsee = await fetch(
"https://example.com/index.php?/cart/v1",
{
method: "POST",
headers: {
Accept: "application/json, text/javascript, */*; q=0.01",
"Accept-Language": "de,en-US;q=0.7,en;q=0.3",
"Accept-Encoding": "gzip, deflate, br",
"X-CSRF-Token": "123",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"X-Requested-With": "XMLHttpRequest",
Origin: "https://example.com/",
DNT: "1",
Connection: "keep-alive",
Referer: "https://example.com/index.php?/products/",
Cookie: "SESSIDe08a=123abc; Cart-Session=123abc",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
Pragma: "no-cache",
"Cache-Control": "no-cache",
},
body: "cat_id=4&domain[id]=13&domain[name]=NEWDOMAINNAME.at&domain[period]1&domain[type]=register",
}
);
Now, pardon my ignorance (my backend knowledge is very limited), how do i set cookies to mydomain.com
(my shop app) from my nextjs api route assuming i'm allowing CORS for that?
I'd appreciate any help or a link with an example.