#Redirect ends up somewhere completely else

23 messages · Page 1 of 1 (latest)

honest berry
#

So I've blown my mind today, I'm working with the Stripe API which you provided a redirect_url, i've set that url to a GET route which should be all good and always worked, but now, I am ending up at some complete different page, and every time its a different page, like, I never ever defined that page anywhere, but I end up magically at that page, sometimes I do end up at the correct page but with a to many redirects error. But like, every time I click "confirm payment" its a complete guess on which route I am ending up.

I've just defined my route like normally: Route::get('/complete/{product:id}/ideal', [Site\Store\CompletePurchaseController::class, 'ideal']);

and my controller is actually completely empty.

So my question here is, how can I debugg this and how can it happen?
Is there some command which I can run to see the live redirects / get requests?

strong flame
#

I highly doubt Stripe would randomly redirect you to different URLs. It more likely sounds as if you have a middleware that does some redirecting, Laravel can't really show those as there's endless possibilities. So I'd advice you to use your browser's devtools, it has a network tab where you can enable "preserve log", there you can see what's happening and which requests the browser makes. It'll show you redirects. From there you know the routes, go through the logic, go through the attached middleware to that route etc

honest berry
strong flame
#

Yeah okay, that wasn't entirely clear to me, as you didn't say it actually redirects to the correct route and then redirects somewhere else (in your app) or if you just meant that Stripe was randomly redirecting you to different URLs

honest berry
#

aa my bad, failed to mention that.
Well, it seems to be redirecting yea, first to the correct ideal route, but after that to a extremely random locale.json translation file. But I have absolutely no idea why.

#

the complete controller function doesn't get executed either

#

there isn't any middleware on the route expect for the default web

strong flame
#

Your web group probably contains middlewares, and there's the global middlewares, perhaps you added some there?

#

Or a package is adding middleware to the web group automatically (which is harder to debug)

#

But a locale.json sounds like some sort of translations package that does something funky

#

I think Telescope can show you the middleware that are attached to that route tho. And there's always the possibly to use xdebug and set breakpoints

honest berry
#

I've tried a bit further, and found out that when I make a function inside the router file it self it does activate, so the issue would be somewhere between the route call and the controller

#

but even when I extend the default Illuminate\Routing\Controller it still happens

#

I am not doing anything wrong here am I?

Route::group(['prefix' => '/complete/{product:id}'], function () {
    Route::get('/ideal', [Site\Store\CompletePurchaseController::class, 'ideal']);
});```

```php
<?php

namespace Pterodactyl\Http\Controllers\Api\Site\Store;

use Pterodactyl\Models\Product;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Log;
use Pterodactyl\Http\Requests\Api\Site\CompletePaymentRequest;
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;

class CompletePurchaseController extends Controller
{
    public function ideal(Product $product,  CompletePaymentRequest $request)
    {
        Log::info('test');
    }
}```
#

aa the issue was in the Request

#

I am an idiot

#

thanks for the help mate, appreciate it

#

CompletePaymentRequest was the issue, based on your reaction 😂 @strong flame

strong flame
honest berry
#

I have no idea either, its litterly as basic as:

<?php

namespace Pterodactyl\Http\Requests\Api\Site;

use Illuminate\Foundation\Http\FormRequest;

class CompletePaymentRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'redirect_status' => 'required|string',
            'payment_intent' => 'required|string',
        ];
    }
}```
#

or is it because authorize is a required function?

#

aa the issue was actually something being required but not provided, no idea why that redirected me like that, but its solved now