#BarrelRider

1 messages Β· Page 1 of 1 (latest)

raw heronBOT
golden tusk
#

Do you have a screenshot of the error?

sleek girder
#

sure gimme a sec

#

basically all I am doing is getting the URL and pushing user to stripe page, maybe I am not understanding what the real problem here is

golden tusk
#

Ah! Okay, so it looks like you're trying to redirect via XMLHttpRequest. Are you using Javascript at all? Or just PHP+Laravel?

sleek girder
#

I am using JS too (Vue3 + InertiaJS) however I thought that if I just jam that into routes it will be easier so I did it like that:

Route::get('/account/my-subscription',function (Request $request) {
        return redirect()->away(auth()->user()->billingPortalUrl(route('dashboard')));
    })->name('stripe.billing-portal');

I can pass to URL to the frontend and try from there, is that going to be better?

golden tusk
#

Exactly! That's why I asked if you were using JS. So yeah, the problem with using XMLHttpRequest that it's designed to make a request, get a response back, and then you do something with the response in your code. It's not meant to be used with server-side redirects. Additionally, they only work when making requests to/from the same origin that the user’s app was loaded from (hence the CORS error)

#

So yes: pass the URL to the frontend and perform a regular HTTP redirect

sleek girder
#

Yeah I thought I will have to add my origin in cors settings on stripe page. Ok that is totally ok and makes sense. Thanks for that. You guys ahve an excellent support I must say!

golden tusk
#

Luckily we see this exact error a lot. Happy to help!

#

P.S. great handle --> BarrelRider πŸ§™β€β™‚οΈ πŸ’ πŸ‰ πŸ§β€β™‚οΈ