
I am trying to set Cookies in PowerApps Portals from Azure Function like below.
Date.prototype.addHours = function(h) {
this.setTime(this.getTime() + (h*60*60*1000));
return this;
}
context.res = {
// status: 200, /* Defaults to 200 */
headers: {
'Set-Cookie': `jwt=${token}; Expires=${new Date().addHours(8)}; Path=/; Secure; HttpOnly; SameSite=Strict`
}
};
I am not able to see Cookies getting set in Browser Cookies.
Hi @akashu912 ,
not sure, but the function will have a diffrent site/url than your portal i assume. So i assume that the cookie will be set for the site of the function and not on the portal and as cookies should be (as you did) be for the same site i think, its not possible that way.
Did not try, but may be if you make both your function AND the portal available via a reverse proxy, this might work as both sites appear to the browser as one site.
One possibility to do so is using Azure Frontdoor. ( https://docs.microsoft.com/en-us/power-apps/maker/portals/azure-front-door ). I tried yesterday for a completely diffrent scenario a nginx container working as a reverse proxy for my functions and that worked very well (but of course more complicated to set up).
Thanks for this great question,
Christian