Redirect Laravel to Stripe session URL
P粉897881626
P粉897881626 2023-08-07 18:33:06
0
1
590
<p>After creating the Stripe checkout session in my controller, I am trying to redirect it by using </p> <pre class="brush:php;toolbar:false;">return redirect($session->url);</pre> <p>But I keep getting a CORS error. <br /><br />I can add the URL and go there manually without any problems. <br /><br />However, according to this article</p><p><br /></p> <blockquote> <p>Getting a CORS error when trying to onboard users to Stripe Connect with Node.js</p> </blockquote> <p>The solution is to return the URL from the server to the client and let him redirect from there. <br /><br />Can anyone tell me how to do this in Laravel?</p><p><br /></p>
P粉897881626
P粉897881626

reply all(1)
P粉617237727

You can return the URL instead of redirecting:

return response()->json([
    'redirect_url' => $session->url
]);

and redirect the user from the client. You will get the redirect url in the JSON response. Handle it accordingly.

Assuming the client uses AJAX, you can use the following command to redirect the user:


success: function (data) {
    window.location.href = data.redirect_url;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template