I was trying to implement cross-domain authentication for my domain and other sub-domains. Currently, my backend is running through firebase cloud functions. So, my backend domain is like https://my-region-firebase-project-id.cloudfunctions.net
.
I was adding the cookie like this:
res.cookie("foo", "bar", {
domain: "mydomain.com",
path: "/",
httpOnly: false,
maxAge: 1209600000,
sameSite: "None",
secure: true
});
This wasn't set the cookie to my front end. Saying This attempt to set cookie via set-cookie header was blocked because its domain attribute was invalid regards to the current host url
I even tried to put a dot before the domain like this: .mydomain.com
. But still the same error.
I can't add a custom domain to my firebase cloud functions, since firebase doesn't support a custom domain for other regions except us-central1.
Did I missing something or not? Or is there any workaround with it?
NB: I am able to set cookies from the cloud function, the problem is the function domain and my frontend domain is completely different.