Is it possible to set cookies in plumber when dealing with cors connections?
I have an angular app (say running on localhost:4200) and plumber api (say on localhost:8000), just trying to use the example code from documentation:
#* @get /sessionCounter
function(req){
count <- 0
if (!is.null(req$session$counter)){
count <- as.numeric(req$session$counter)
}
req$session$counter <- count + 1
return(paste0("This is visit #", count))
}
I register the sessionCookie() hooks on the rooter, so this works when I visit localhost:8000/sessionCounter in browser, but not from the angular app.
Is there any setting I am missing here?
I only added res$setHeader("Access-Control-Allow-Origin", "http://localhost:4200")
for serving cors requests, do I need something else?