Shopfiy custom app links are not working inside shopify iframe kyon147/laravel-shopify package

495 Views Asked by At

I am using kyon147/laravel-shopify package which is extending from osiset user. The app was already built on another laravel-shopify package that is abandoned now. I have upgraded the package. I fixed all the reported issues.

The problem I am facing is whenever I click on any of the link of the app that is hosted locally. None of the links work. The screen keeps flashing. When I click on the sidebar of shopify all the links work fine.

I have checked X-frame-options' is also set to false using grep -r 'X-Frame-Options'I tried to Log the session data. The array is empty in that even on homepage but after I use dd inHomeController`. It returns few values. I have cross-checked log file. The network tab has returns success code 302 for app bridge which means there is no problem as it is only redirecting. Only working links are those, which are not embedded in shopify app. The link

<a  class="Polaris-Breadcrumbs__Breadcrumb" href="{{url('/home')}}" data-polaris-unstyled="true">

is not working. But the following link working

<a class="btn btn-lg btn-success" href="https://wyday.com/limelm/signup/" target="_blank" role="button">Sign up on LimeLm</a>

The only difference I found in the Network tab is how the embedded and non-embedding links are redirecting. Following is a non-embedded link

non embedded link image

Following embedded this also include the flashing screen embedded link

I have added all my links to allowed redirects as well. enter image description here

1

There are 1 best solutions below

0
On

I had made the same mistake in my previous project, but I found a solution for the Kyon147\laravel-Shopify package.

If you are using the blade file then follow this code:

Replace the Route or URL link to the URL::tokenRoute facades.

For example:

<a  class="Polaris-Breadcrumbs__Breadcrumb" href="{{ URL::tokenRoute('/home') }}" data-polaris-unstyled="true">

If you are using the controller file then follow this code:

Replace the redirect()->route() or redirect() helper to Redirect::tokenRedirect(); 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 
}