Cannot redirect to Discourse. Error: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource

Another option is to set a login redirect on your AJAX login. I just tried it with an AJAX login plugin that has a login redirect option. If you’re using custom code you can probably do the same thing. Setting the login redirect to
http://forum.example.com/session/sso?return_path=http://example.com/your-welcome-page
should get users logged into Discourse without errors. You need to make sure that the Discourse setting ‘sso allows all return paths’ is enabled for this to work.