Cookies not setting on custom domain

I’ve deployed an app on Netlify with a custom domain, meaning I can access it via both the domain along with my custom one.

The issue I’m having is that cookies do not seem to be setting when going via my custom domain, whereas they set fine for the URL. This means my login system doesn’t function via the actual domain I want it to work on.

This seems to be the opposite to what is suggested would be a potential issue in the docs, with it suggesting I’m more likely to run into the issue on the domain instead, but that’s the one that’s working fine.

Wrt technologies, I’m using SvelteKit with Lucia Auth, and Lucia uses SameSite: lax by default, so that suggestion I’ve had has already been explored. I’m using Cloudflare for domain hosting, where I added the relevant DNS records. The site itself loads completely fine and functions as normal, other than the setting of cookies on the primary domain.

My guess would be this has something do with it being hosted on the domain, and the domain I actually want just forwarding the request to there. But not sure how to resolve or if my hypothesis is correct.

You might not be setting the domain correctly for the cookies. But hard to say without seeing your site.