Search code examples
djangocookiessveltecookie-httponly

Directly setting http only cookie in browser from django (frontend is svelte)


I am trying to send a http-only cookie from django response to svelte. The cookie reaches svelte using fetch, but it doesn't come into the browser. Is there a way to set cookie from django directly in the browser? Without using svelte? If no, then how to set an http-only cookie using svelte. Any help is much appreciated!!!


Solution

  • Make sure you have this code in Django:

    CORS_ALLOW_CREDENTIALS = True
    
    CORS_ORIGIN_WHITELIST = (
        'localhost:PORT'
    )