-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InvalidRequestError: Request does not contain a host query parameter #1234
Comments
Did you figure it out? |
Access the app from the store (if installed), or from the partner account (if not yet installed on a store). The Shopify system adds a |
With the hooks they provided, the shop is added to the query parameter, but I don't see where they add the host in the hook? |
To which hooks are you referring? |
I think you mean when going to the app first time the host is added in the url? I'm getting that error after I call the api from the frontend. |
What hooks are you using to call the API from the frontend? Also, what version of App Bridge is being used? |
first time call issue is resolve but in second condition "when I'm calling the API from the front-end" you are right I'm also facing same issue due to Shopify middle-ware
currently resolve by bypassing this route middle-ware any better solution for this issue please guide. |
Update: Here's why this might be happening and how to fix ittldr: your routes might not be completely handling your request, so it continues by default to the Let's say for example, you are trying to send a fetch request from your frontend to This may be happening because of how your route is set up. You need to make very sure that you have set up your Express App in the following ways:
The reasons: When your Express Server receives the request, if you don't have a route set up, or if that route passes it onwards instead of returning a response, then the Similarly, if you added your route below that middleware, it would be too late, because the middleware would have already been applied. Anytime the I was experiencing this problem simply because I was still adding routes, debugging them as I went along, and I didn't realise the above requirements. I might make a PR to add clarifying comments to the Express template, because as it's currently set up, it's not clear what is going wrong. So, if you want to fix this, check that your route is set up properly. If everything's set up right, the request will be caught, handled, responded to, and the middleware will never get applied. Original PostI originally posted a fix, to add the Hi, I'm a fellow dev working on a Shopify App, who's also experiencing this after creating an app from shopify-cli 3.45.1. I have a solution, even though I don't understand why it's necessary. The solution involves modifying the frontend code to add the I didn't have to remove the Instead, I modified the In that function, I added some code that will add the
and here's the new
Note that in my app, the Disclaimers:
|
Unfortunately neither of @bashunaimiroy 's solution worked for me. I have another theory. When I console logged shop and host, host has a whitespace. So maybe If you are developing a Shopify app, I'm sure that you are using a session storage. Simply delete the entry that corresponds to your test shop, and Shopify will create a new host and session. The new host did not have a whitespace, so the app under development ran fine for me after the deletion of the previous session. |
Ok I spoke too soon, every subsequent request after generating a new session host fails and has a whitespace. Something is happening but if you delete the session every time it works... obviously not a permanent solution. |
@bashunaimiroy after applying your two fixes, I got this error in my dev environment when trying to fetch with the authenticated fetch:
Shopify please have a look 😿 |
Okay here is the work around I found, When making a request on the frontend of your application to the backend, template the value for your host into the requested url. Below is an example via Shopify's authenticated fetch method. const fetch = useAuthenticatedFetch();
//fetch data points data from API using the fetch function;
const onSubmit = async () => {
//host is added here to bypass shopify.ensureInstalledOnShop() in the backend;
const host = `host=${window.__SHOPIFY_DEV_HOST}`
const url = `/api/points?${host}`;
const method = 'GET';
const response = await fetch(url, { method, headers: { 'Content-Type': 'application/json' } });
if (response.ok) {
const data = await response.json();
console.log(data);
}
}; |
@mkevinosullivan any thoughts. I'm using tanStack with useAuthenticatedFetch() method and app-bridge-3.1.0. When i open the app using partner account or from the store during development it logs this for any backend hook call :- [shopify-app/ERROR] ensureInstalledOnShop did not receive a shop query argument | {shop: undefined} Everything was working fine on 28th June, 2023. Are there any updates regarding this issue ? |
I have updated the shopify/cli and shopify/app to 3.47.2 and also updated the react-router-dom to 6.14.1 and it worked for me. |
I'm creating a Shopify app using node with PostgreSQL my app working fine on local with Ngrok but when i deploy on Heroku on calling app with shop it returns error.
[shopify-app/INFO] Running ensureInstalledOnShop
/app/web/node_modules/@shopify/shopify-api/lib/error.js:13
var _this = _super.apply(this, tslib_1.__spreadArray([], tslib_1.__read(args), false)) || this;
^
my root package.son dependencies
route calling
https://{shopurl}.herokuapp.com/?shop={shopname}myshopify.com
The text was updated successfully, but these errors were encountered: