Closed nandpalmohit closed 1 year ago
What version of the package are you using, and can you also share your controller code as well.
It's working fine for me and the infinite loop issue you are experiencing sounds more like a set up issue, related to host
etc - so I need more information.
me too. When I want to go to products or customer pages through routes and controller, it is not working. The pages are not working properly. Showing white screen.
Route::get('/', function () { return view('dashboard'); })->middleware(['verify.shopify'])->name('home');
Route::get('products', function () {
return view('products');
})->middleware(['verify.shopify'])->name('products');
Route::get('customers', function () { return view('customers'); })->middleware(['verify.shopify'])->name('customers');
@usaikoo do you see any errors in the dev tools console?
@usaikoo do you see any errors in the dev tools console?
hi, only the default routes you mentions in doc are working. when I try to use custom routes, the authentication token url not redirecting to this custom routes. but when I test with the routes in your doc provided, it works 'route_names' => [ 'home' => env('SHOPIFY_ROUTE_NAME_HOME', 'home'), 'authenticate' => env('SHOPIFY_ROUTE_NAME_AUTHENTICATE', 'authenticate'), 'authenticate.token' => env('SHOPIFY_ROUTE_NAME_AUTHENTICATE_TOKEN', 'authenticate.token'), 'billing' => env('SHOPIFY_ROUTE_NAME_BILLING', 'billing'), 'billing.process' => env('SHOPIFY_ROUTE_NAME_BILLING_PROCESS', 'billing.process'), 'billing.usage_charge' => env('SHOPIFY_ROUTE_NAME_BILLING_USAGE_CHARGE', 'billing.usage_charge'), 'webhook' => env('SHOPIFY_ROUTE_NAME_WEBHOOK', 'webhook'), ],
edit: when I go to products route by this link,
https://29fe-66-131-190-55.ngrok-free.app/authenticate/token?shop=melaravelshop.myshopify.com&target=/products |
---|
as you see the token?___ is missing in it.
My bad, I found the solution in your doc, 😄 now I got it.
For non-SPAs, you will need to visit the /authenticate/token route between each request. You can use the tokenRoute and tokenRedirect helpers.
In controller, (example for tokenRoute): $orders = URL::tokenRoute('orders.view', ['id' => 1]);. In Blade, (example for tokenRoute): Order #1
In controller, (example for tokenRedirect): return Redirect::tokenRedirect('orders.view', ['id' => 1]);
With these helpers, they will first redirect you to the /authenticate/token page to get a new Shopify session token, then redirect you to the destination route.
@Kyon147 I am using the latest version of the package.
In route file:
Route::middleware(['verify.shopify'])->group(function () {
Route::get('/', function() {
return view('pages.home', );
})->name('home');
Route::get('/dashboard', function() {
return view('pages.dashboard', );
})->name('dashboard');
Route::get('/services', function() {
return view('pages.services', );
})->name('services');
});
I am not getting any route or any URL that is wrapped under middleware
. It shows a white blank screen without any error message.
I guess it is an error due to the access-token.
I have a solution for this issue, and here's an answer for it.
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
I have a solution for this issue, and here's an answer for it.
If you are using the
blade
file then ReplaceRoute()
orURL()
helpers toURL::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 Replaceredirect()
orredirect()->route()
helpers toURL::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
This is correct, it is because these helpers also pass the host
param. It is mentioned in the wiki, if anyone wants to know more.
Expected Behavior
Returns a new page from
ConfigController
with adashboard
page view.Current Behavior
It goes into an infinite loop and doesn't get any page view
Context
I created a new route inside the
verify.shopify
middleware. Here's my code fromweb.php
: