Custom header from remote site

AI-generated summary

User deltaskelta had an issue with a custom header on their remote Django site, which was not recognizing the user’s login status when loaded via an AJAX request from Discourse. The issue was due to the request not including credentials, causing the site to treat it as if the user was not logged in. deltaskelta found the solution by using AJAX and including credentials in the CORS request, allowing the site to correctly authenticate the user.

I have a custom header on my remote django site that renders some information so I decided to make a view for it and use an ajax request to load it into my discourse header when the page loads and it renders everything I need…

It worked beautifully except that since the request is coming from discourse and not the browser os the user, it is not showing that I am logged in in my custom header. (I am using sso, working fine, discourse avatar showing, and logged in, only my custom header links are showing as if I am not logged in on my main site)

How could I fix this? Is there a way I can make the ajax request come from the browser so it would be the actual request user and my site would show them as logged in?

or should I go a different route and send some of the user info along with the request to authenticate them?

for an example here is the jquery that gets the header menu:

<script>

    $(document).ready(function() {
        $.get( "https://my-domain.com/discourse/get-menu", function( data ) {
            $("#LLmenu").html( data );
        });
    })
</script>

I had the cause wrong, it was due to not including credentials in a CORS request, solved by using ajax and including the credentials