Access to XMLHttpRequest at 'https://billing.stripe.com/p/session/test_YWNjdF8wbnJCRFhHRjljcWg1cEV4SldKcixfT01UQ2lrRHlvYmFpR2lpUm9SODM2SThEcjdoUlphSg0100Q5ftkFoj' (redirected from 'http://codecourse_build_a_forum_with_inertia.test/test/payments/stripe-billing-portal') from origin 'http://codecourse_build_a_forum_with_inertia.test' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
And the redirect does not happen.
How can I fix this?
Found a solution thanks to Robert Boes on Discord.
You shouldn't call that route through XHR, just a regular anchor would suffice (my href was using Inertia's <Link>).
When I replace it with a regular <a :href it works. Or, if I use <Link :href with return Inertia::location($url); in the controller (make it an external redirect that Inertia understands; https://inertiajs.com/redirects#external-redirects), that also works.
@connecteev Thanks man. I was wondering why my requests were failing despite using ngrok for https. At the end it was an XHR issue. I was using useForm from Inertia for the post request as I had payload. For anyone else wondering, here's a sample controller code: