skip to Main Content

I am using Kyon147/laravel-shopify package for my laravel shopify app integration and I just found that in verify.shopify middleware custom routes are not working while I call the same routes outisde middleware and it’s working fine.

I am using Kyon147/laravel-shopify package for my laravel shopify app integration and I just found that in verify.shopify middleware custom routes are not working while I call the same routes outisde middleware and it’s working fine.

route::middleware(['verify.shopify'])->group(function () {
    // index page
    Route::get('/', [ConfigController::class, 'viewWelcome'])->name('home');

    // app - plan page
    Route::get('/plan', [ConfigController::class, 'viewPlans'])->name('plan');

});

Route::get('/privacy', [PagesController::class, 'privacyPolicyPage'])->name('pages.policy'); // contact support page

Here, /privacy route is completely working outside the middleware.

Package Name: Kyon147/Laravel-shopify

2

Answers


  1. Chosen as BEST ANSWER

    I have a solution for this issue, and here's an answer for the Kyon147Laravel-Shopify package.

    If you are using the blade file then Replace Route() or URL() helpers to URL::tokenRoute() facades.

    For example:

    <a class="btn btn-sm py-3 w-sm-100 w-auto" href="{{ URL::tokenRoute('products') }}">Products </a>
    

    If you are using the controller file then Replace redirect() or redirect()->route() helpers to URL::tokenRoute() facades.

    public function home(Request $request)
    {
        return view('home');  // return home page
    }
    
    public function dashboard(Request $request)
    {
        return Redirect::tokenRedirect('home');  // redirect to home route
    }
    

    This code is working for me


  2. It seems like you are encountering an issue with the verify.shopify middleware from the Kyon147/Laravel-shopify package not working as expected for your custom routes. Let’s troubleshoot this issue step by step:

    1. Middleware Configuration: First, make sure you have properly configured the verify.shopify middleware in your Laravel application. Check your AppHttpKernel.php file and ensure that the middleware is registered correctly. It should look something like this:
    protected $middlewareGroups = [
        'web' => [
            // ...
            Kyon147LaravelShopifyMiddlewareVerifyShopify::class,
            // ...
        ],
        // ...
    ];
    
    1. Middleware Parameters: Verify if the verify.shopify middleware requires any additional parameters or configuration. Some middleware in Laravel may require specific settings or parameters to work correctly. Review the documentation of the Kyon147/Laravel-shopify package or the middleware itself to ensure it’s configured correctly.

    2. Middleware Order: Middleware order matters in Laravel. Ensure that the verify.shopify middleware is placed in the correct order within the middleware group. If it’s supposed to run before your custom routes, make sure it appears before those routes in the web middleware group.

    3. Middleware Exemptions: Check if the verify.shopify middleware has any route exemptions configured by default. It’s possible that certain routes are excluded from the middleware’s action.

    4. Middleware Logs/Debugging: If the issue persists, consider adding some logging or debugging statements within the verify.shopify middleware to see if it’s being triggered as expected. This can help you identify whether the middleware is the source of the problem.

    5. Package Documentation and Support: If you’re still facing issues after checking the above steps, consult the official documentation for the Kyon147/Laravel-shopify package. Additionally, check for any open issues or discussions on the package’s GitHub repository or community forums. The package’s author or other users may have encountered similar issues and could provide guidance or solutions.

    Remember to clear your Laravel cache and routes using php artisan cache:clear and php artisan route:clear after making changes to your routes or middleware to ensure that the changes take effect.

    By following these steps and consulting the package documentation and community support, you should be able to resolve the issue with your custom routes not working as expected within the verify.shopify middleware.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search