Shopify / shopify-app-js

MIT License
299 stars 120 forks source link

`ensureInstalledOnShop` did not receive a shop query argument #161

Open kelreel opened 1 year ago

kelreel commented 1 year ago

Issue summary

During moderation in the Appstore, I have already received a reject several times. There are errors in the moderator's account when changing the subscription plan. I see in the production logs ensureInstalledOnShop did not receive a shop query argument. I can't figure out why this is happening. There is no such error on my dev/prod accounts, including test staff accounts.

How can more data be collected when this happens? I thought the issue would be solved after closing https://github.com/Shopify/shopify-app-js/issues/94, but these errors are again...

Packages:

Logs:

[shopify-app/ERROR] ensureInstalledOnShop did not receive a shop query argument | {shop: undefined}
[shopify-app/INFO] Running ensureInstalledOnShop
[shopify-app/ERROR] ensureInstalledOnShop did not receive a shop query argument | {shop: undefined}
[shopify-app/ERROR] ensureInstalledOnShop did not receive a shop query argument | {shop: undefined}
[shopify-app/INFO] Running ensureInstalledOnShop
....

Shopify.ts

export const shopify = shopifyApp({
    api: {
        apiKey: process.env.SHOPIFY_API_KEY!,
        apiSecretKey: process.env.SHOPIFY_API_SECRET!,
        scopes: process.env.SCOPES!.split(','),
        hostName: process.env.HOST!.replace(/https?:\/\//, ''),
        hostScheme: 'https',
        apiVersion: LATEST_API_VERSION,
        isEmbeddedApp: true,
        logger: {
            level: LogSeverity.Debug,
        },
        ...(process.env.SHOP_CUSTOM_DOMAIN && {
            customShopDomains: [process.env.SHOP_CUSTOM_DOMAIN],
        }),
        billing: {
            [BillingPlan.Pro]: {
                interval: BillingInterval.Every30Days,
                amount: BillingPlans.Pro.price,
                currencyCode: 'USD',
                replacementBehavior: BillingReplacementBehavior.ApplyImmediately,
                trialDays: 3,
            },
        },
    },
    webhooks: {
        path: '/api/webhooks',
    },
    auth: {
        path: '/api/auth',
        callbackPath: '/api/auth/callback',
    },
    sessionStorage: new PostgreSQLSessionStorage(new URL(process.env.POSTGRES_URL!), {
        sessionTableName: 'shopify_sessions',
    }),
    useOnlineTokens: true,
});

App.ts

export async function createServer(isProd = process.env.NODE_ENV === 'production') {
    const app = express();

    // CSP x-frame header
    app.use(async (req, res, next) => {
        const shop = shopify.api.utils.sanitizeShop(req.query.shop as string);

        res.setHeader(
            'Content-Security-Policy',
            `frame-ancestors https://admin.shopify.com ${shop ? 'https://' + encodeURIComponent(shop) : ''}`,
        );
        next();
    });

    app.get(shopify.config.auth.path, shopify.auth.begin());
    app.get(
        shopify.config.auth.callbackPath,
        shopify.auth.callback(),
        async (req, res, next) => {
            const session = res.locals.shopify.session;
            await saveShopData(session);
            initProductWidget(session.shop);
            next();
        },
        shopify.redirectToShopifyOrAppRoot(),
    );

    app.post(shopify.config.webhooks.path, shopify.processWebhooks({ webhookHandlers }));

    // All endpoints after this point will require an active session
    app.use('/api/*', shopify.validateAuthenticatedSession());

    // All endpoints after this point will have access to a request.body
    // attribute, as a result of the express.json() middleware
    app.use(express.json());
    app.use(urlencoded({ extended: true }));

    app.post('/api/graphql', async (req: Request, res) => {
        try {
            await shopify.api.clients
                .graphqlProxy({
                    session: res.locals.shopify.session as Session,
                    rawBody: req.body,
                })
                .then(data => res.send(data.body))
                .catch(e => res.status(400).send({ errors: e?.response?.errors }));
        } catch (e) {
            console.log(e);
        }
    });

    // controllers...
    app.use('/api/products', ProductsController);
    app.use('/api/files', FilesController);
    app.use('/api/widgets', WidgetsController);

    if (isProd) {
        const compression = await import('compression').then(({ default: fn }) => fn);
        const serveStatic = await import('serve-static').then(({ default: fn }) => fn);
        app.use(compression());
        app.use(serveStatic(PROD_INDEX_PATH, { index: false }));
    }

    app.use('/*', shopify.ensureInstalledOnShop(), async (req, res, next) => {
        const htmlFile = join(isProd ? PROD_INDEX_PATH : DEV_INDEX_PATH, 'index.html');

        return res.status(200).set('Content-Type', 'text/html').send(readFileSync(htmlFile));
    });

    return { app };
}
jt274 commented 1 year ago

Same issue after running the CLI app template.

Shop is passed at first, then disappears.

Logs:

GET /?embedded=1&hmac=X&host=X&locale=en&prefetch=1&session=X&shop=SHOP
[shopify-api/INFO] version 6.2.0, environment Node v18.15.0
[shopify-app/INFO] Running ensureInstalledOnShop
[shopify-app/INFO] App is installed and ready to load | {shop: SHOP.myshopify.com}
GET /index.jsx
GET /dev_embed.js
GET /@react-refresh
[shopify-app/INFO] Running ensureInstalledOnShop
[shopify-app/ERROR] ensureInstalledOnShop did not receive a shop query argument | {shop: undefined}

App then terminates to a blank page.

olafghanizadeh commented 1 year ago

I'm having the same issue on requests made from the embedded app.

ejprismfly commented 1 year ago
[shopify-app/INFO] Running ensureInstalledOnShop
[shopify-app/ERROR] ensureInstalledOnShop did not receive a shop query argument | {shop: undefined}

Can't deploy right now, is not loading properly.

FourLineCode commented 1 year ago

Why is this issue not getting any attention? This has been an issue since January - #94

Apps are getting rejected in the review process for this issue. Can't even downgrade to an older version, since alot of the new version of other session packages are not compaitable/having issues.

AleksandrBy commented 1 year ago

Same. Logs: [shopify-app/INFO] Running ensureInstalledOnShop ++++++++++++ START LOAD session ++++++++++++ START LOAD session [shopify-api/INFO] Beginning OAuth | {shop: rthreadstestsite.myshopify.com, isOnline: false, callbackPath: /api/auth/callback} [shopify-api/ERROR] Invalid OAuth callback | {shop: rthreadstestsite.myshopify.com, stateFromCookie: 976561067937147} [shopify-app/ERROR] Failed to complete OAuth with error: Error: Invalid OAuth callback. [shopify-app/INFO] Handling request to complete OAuth process [shopify-api/INFO] Completing OAuth | {shop: rthreadstestsite.myshopify.com} [shopify-app/ERROR] ensureInstalledOnShop did not receive a shop query argument | {shop: undefined} [shopify-app/INFO] Running ensureInstalledOnShop

ArasHuseyin commented 1 year ago

I am getting the same error, has anyone already found a solution for it?

[shopify-app/INFO] Running ensureInstalledOnShop [shopify-app/ERROR] ensureInstalledOnShop did not receive a shop query argument | {shop: undefined}

olafghanizadeh commented 1 year ago

Pining @mkevinosullivan and @paulomarg to get any info on this?

kelreel commented 1 year ago

Requests for static files will still generate ensure Installed On Shop did not receive a shop query argument | {shop: undefined} error until they are cached by the browser. This is relevant if authorization, authorization redirects, exitframe, re-authentication are configured correctly and static serving is used from node app.

ChrisFH-UC commented 1 year ago

I also seem to be receiving the error

AleksandrBy commented 1 year ago

Any movement?

jt274 commented 1 year ago

I was able to fix this.

Unfortunately, it took deleting the app, starting from the current CLI app template, and taking about a week to put my previous app (based on their old template) into the new template and very painfully convert it again to typescript. Huge pain, but works now. Old version used next, new version uses express.

This is after the app was delisted due to breaking changes Shopify made that I did not seem to be made aware of.

olafghanizadeh commented 1 year ago

I was able to fix this.

Unfortunately, it took deleting the app, starting from the current CLI app template, and taking about a week to put my previous app (based on their old template) into the new template and very painfully convert it again to typescript. Huge pain, but works now. Old version used next, new version uses express.

This is after the app was delisted due to breaking changes Shopify made that I did not seem to be made aware of.

I'm having this issue on an app that I created from the CLI app template just earlier this year, so does not seem like the solution to this issue.

It seems like the requests sent from the frontend app is missing the shop query parameter from url's and thus the ensureInstalledonShop middleware fails.

AleksandrBy commented 1 year ago

Dear Developers, @mkevinosullivan @cquemin @paulomarg @refactor-this @teddyhwang @ajshepley

I am writing to bring to your attention a critical issue that is affecting the performance of the Shopify apps developed using your library. As you may already be aware, there is a bug in your code that needs immediate attention.

This issue has caused inconvenience and loss of revenue for many businesses, including small companies and individual developers like myself, who rely on your library to build applications. It is not only frustrating but also damages the reputation of our companies and the trust of our users.

I understand that fixing bugs can be a challenging and time-consuming task. However, I implore you to prioritize this issue and provide a resolution as soon as possible. If a quick fix is not feasible, it would be appreciated if you could suggest a temporary solution or workaround to mitigate the impact of the bug on our applications.

I am confident that you will address this problem promptly and efficiently, and I appreciate your efforts in ensuring that your library provides a reliable and stable foundation for the development of Shopify apps.

Thank you for your attention to this matter.

Sincerely,

@AleksandrBy

bashunaimiroy commented 1 year ago

I found an explanation for this. There's a good chance that it is happening because you did not set up your Express Routes properly.

Look at this post for an explanation of how to set them up properly, and why you would receive these errors from ensureInstalledOnShop if your routes are not set up properly.

--

If the above does not apply to you, here's a fix to add the shop parameter:

This fix is with a Shopify app created from Shopify-CLI 3.45.1. That generates an app with an Express Server backend and a React frontend. I'm sure many people reading this thread have done the same.

Using this app, which includes the ensureInstalledOnShop middleware by default, we start to get this error when we try to send fetches from the frontend.

My Fix

I added some middleware to my Express Server app, to add the shop parameter to every request's query parameters. It takes the shop value from the res.locals.shopify.session, which is added by the shopify.validateAuthenticatedSession middleware. Here's the code:

const addSessionShopToReqParams = (req, res, next) => {
  const shop = res.locals?.shopify?.session?.shop;
  if (shop && !req.query.shop) {
    req.query.shop = shop;
  }
  return next();
}
app.use("/api/*", shopify.validateAuthenticatedSession()); 
// we have to add our new middleware *after* the shopify.validateAuthenticatedSession middleware, like so:
app.use("/*", addSessionShopToReqParams)

The Result

ensureInstalledOnShop doesn't complain about missing a shop query argument anymore!

Next, it complains about missing a host query argument. Here's my fix for that!

Disclaimers

xegulon commented 1 year ago

Shopify please solve this

bashunaimiroy commented 1 year ago

@xegulon did my steps in the above post work for you? Either checking your routes, or the fix?

xegulon commented 1 year ago

@bashunaimiroy I have the problem with the exact template I got from pnpm create @shopify/app

My app is deployed in an Amazon EBS environment

When I try to install the app for testing on my dev store, I have endless ensureInstalledOnShop did not receive a shop query argument errors

bashunaimiroy commented 1 year ago

@xegulon Could you clarify, is this happening immediately after you click "Install"?

And if so, what's the path of the request that is causing this error? Is it one of these: <your-deployed-app-url>/api/auth, or <your-deployed-app-url>/api/auth/callback?

If that's the case, then it would be good to look in web/shopify.js and ensure that you have those set up as your auth.path and auth.callbackPath properties, e.g.

  auth: {
    path: "/api/auth",
    callbackPath: "/api/auth/callback",
  },

And that you're using them in your server code, as per here.

If you've created your app from the Shopify CLI as you mentioned, then everything should be fine- what I mentioned are the default setting values.

If on the other hand these errors are happening in response to another request, like one that your app is making from its frontend, then you may have to carefully debug to make sure that your server is properly responding to the request, as I outlined in my answer above. Good luck!

jarrad1978 commented 1 year ago

I'm not sure if this bit of info is going to be applicable to your particular issue with ensureInstalledOnShop not receiving a shop param but in my application I was having the same issue and I fixed it by reordering the imports. When I was getting the error in regards to the shop param missing I had a static asset being imported prior to the useAuthenticatedFetch import, once I moved the import for my static asset after the useAuthenticatedFetch import it began working.

Using imports in this order cause the error to occur in my app

import { useState, useEffect, useRef } from "react";
import {
    AlphaCard,
    Button,
    Image,
    Layout
} from "@shopify/polaris";
import { MyStaticImage } from "../assets/index.js";
import { Toast } from "@shopify/app-bridge-react";
import { useAuthenticatedFetch } from "../hooks";

After reordering the imports, the error ceased

import { useState, useEffect, useRef } from "react";
import {
    AlphaCard,
    Button,
    Image,
    Layout
} from "@shopify/polaris";
import { Toast } from "@shopify/app-bridge-react";
import { useAuthenticatedFetch } from "../hooks";
import { MyStaticImage } from "../assets/index.js";
murphy2mo commented 1 year ago

Start the frontend project with Vite during development to solve this problem.

AleksandrBy commented 1 year ago

Dear @bashunaimiroy,

I would like to express my sincere gratitude for providing me with the clarification. Your insight has been instrumental in helping me comprehend the direction of the error. I attempted to implement the solution you proposed, but unfortunately, it did not yield the desired results. If it's not too much trouble, could you kindly spare some time to take a look at this post? Perhaps I overlooked something, and your expertise could assist me in resolving the issue.

Thank you for your assistance and ongoing support.

I've added console.log in addSessionShopToReqParams function. I see that at first the shop is present, and then it becomes again undefined.

Here is index.js

import { join } from "path";
import { readFileSync } from "fs";
import express from "express";
import serveStatic from "serve-static";

import shopify from "./shopify.js";
import WebhookHandlers from "./webhooks.js";
import { launchCron } from "./helpers/app-functions.js";
import applyAppPublicEndpoints from "./middleware/app-api.js";

const addSessionShopToReqParams = (req, res, next) => {
    const shop = res.locals?.shopify?.session?.shop;
    if (shop && !req.query.shop) {
      req.query.shop = shop;
    }
    console.log('SHOP:', shop, req.query.shop);
    return next();
}

const PORT = parseInt(process.env.BACKEND_PORT || process.env.PORT, 10);
const STATIC_PATH =
    process.env.NODE_ENV === "production"
        ? `${process.cwd()}/frontend/dist`
        : `${process.cwd()}/frontend/`;

const app = express();
launchCron();

app.use(shopify.cspHeaders());

// Set up Shopify authentication and webhook handling
app.get(shopify.config.auth.path, shopify.auth.begin());
app.get(
    shopify.config.auth.callbackPath,
    shopify.auth.callback(),
    shopify.redirectToShopifyOrAppRoot()
);
app.post(
    shopify.config.webhooks.path,
    shopify.processWebhooks({ webhookHandlers: WebhookHandlers })
);

app.use(express.json());

app.use("/api/*", shopify.validateAuthenticatedSession());

app.use("/*", addSessionShopToReqParams);

applyAppPublicEndpoints(app);

app.use(serveStatic(STATIC_PATH, { index: false }));

app.use("/*", shopify.ensureInstalledOnShop(), async (_req, res, _next) => {
    return res
        .status(200)
        .set("Content-Type", "text/html")
        .send(readFileSync(join(STATIC_PATH, "index.html")));
});

app.listen(PORT);

And Here is LOGS from server:

production
[shopify-api/INFO] version 7.0.0, environment Node v18.15.0
Connected to database as id 38868262
Query result: 11
SHOP: undefined rthreadstestsite.myshopify.com
[shopify-app/INFO] Running ensureInstalledOnShop
++++++++++++ START LOAD session
++++++++++++ START LOAD session
SHOP: undefined rthreadstestsite.myshopify.com
[shopify-app/INFO] Running ensureInstalledOnShop
++++++++++++ START LOAD session
++++++++++++ START LOAD session
[shopify-app/INFO] App is installed and ready to load | {shop: rthreadstestsite.myshopify.com}
SHOP: undefined undefined
SHOP: undefined undefined
[shopify-api/INFO] Beginning OAuth | {shop: rthreadstestsite.myshopify.com, isOnline: false, callbackPath: /api/auth/callback}
[shopify-app/INFO] Handling request to complete OAuth process
[shopify-api/INFO] Completing OAuth | {shop: rthreadstestsite.myshopify.com}
[shopify-api/ERROR] Invalid OAuth callback | {shop: rthreadstestsite.myshopify.com, stateFromCookie: 564390550605107}
[shopify-app/ERROR] Failed to complete OAuth with error: Error: Invalid OAuth callback.
SHOP: undefined undefined
[shopify-app/INFO] Running ensureInstalledOnShop
[shopify-app/ERROR] ensureInstalledOnShop did not receive a shop query argument | {shop: undefined}
bithaolee commented 1 year ago

I found a lot of such error logs in the production environment, please solve this problem as soon as possible

ArasHuseyin commented 1 year ago

@bashunaimiroy thank you very much, your solution approach has solved the problem

matija2209 commented 1 year ago

I also have the same issue. The shop query is present on OAuth but disappears as soon as the grant screen process is completed.

matija2209 commented 1 year ago

@ArasHuseyin but does it work when you try to install the app? If I don't include ensureInstalledShop it won't get the merchant to Grant screen.

matija2209 commented 1 year ago

Another thing I noticed is that when it's used on an endpoint it works fine.

app.get("/",shopify.ensureInstalledOnShop(),(req,res)=>{
res.send("Hello")
})

Only when used as middleware it throws and error.

ArasHuseyin commented 1 year ago

@ArasHuseyin but does it work when you try to install the app? If I don't include ensureInstalledShop it won't get the merchant to Grant screen.

yes it does work when i install the app

lamttq97 commented 1 year ago

For me I have a weirder log


2023-06-05 03:18:26 │ backend  │ [shopify-app/INFO] Running validateAuthenticatedSession
2023-06-05 03:18:26 │ backend  │ [shopify-app/INFO] Request session has a valid access token | {shop: MYSHOP.myshopify.com}
2023-06-05 03:18:26 │ backend  │ [shopify-app/ERROR] ensureInstalledOnShop did not receive a shop query argument | {shop: undefined}
2023-06-05 03:18:26 │ backend  │ [shopify-app/INFO] Running ensureInstalledOnShop

This is just me duplicate the query to another component. Call API and it return "No shop provided" in response

js10222 commented 1 year ago

Also been running into the error "ensureInstalledOnShop did not receive a shop query argument | {shop: :undefined}". Currently using the node.js template with redis session storage.

Edit - Solution for us: We found a solution for ourselves and putting it here in case it helps anyone else. Our setup was the node.js app with the Redis adapter on Heroku. We switched from the Redis adapter to the MySQL adapter and we stopped getting that error.

dani-sanomads commented 1 year ago

If you are still getting this error than update the shopify/app , shopify/cli and react-router-dom npm packages.

hassanelnajjar commented 1 year ago

The issue is:- The index.html ask the server for the CSS and js files using these URLs: /assets/1213213.js and /assests/sefsef.css and these files (URLs) do not contain the shop parameters.

A workaround solution is just re-order this middleware to be above the ensureInstalledOnShop.

like this 👎🏾

app.use(serveStatic(STATIC_PATH, { index: false }));

app.use('/*', shopify.ensureInstalledOnShop(), async (_req, res, _next) => {
  return res
    .status(200)
    .set('Content-Type', 'text/html')
    .send(readFileSync(join(STATIC_PATH, 'index.html')));
});
Nedi11 commented 1 year ago

STILL AN ISSUE

ali-faiz-brainx commented 1 year ago

I have the same issue when deploying an app on the server,

Here is the workaround which works for me:

Just add NODE_ENV=production as environment variables on you're a server.

I have also add some other environment variables on the root directory (also in web folder):

SHOPIFY_API_KEY, SHOPIFY_API_DECRET, HOST, SHOP, SCOPES and it works fine for me now.

umutsesen commented 1 year ago

I do not know how, but NODE_ENV=production fixed the issue. @ali-faiz-brainx

I have the same issue when deploying an app on the server,

Here is the workaround which works for me:

Just add NODE_ENV=production as environment variables on you're a server.

I have also add some other environment variables on the root directory (also in web folder):

SHOPIFY_API_KEY, SHOPIFY_API_DECRET, HOST, SHOP, SCOPES and it works fine for me now.

ykyuen commented 1 year ago

I do not know how, but NODE_ENV=production fixed the issue. @ali-faiz-brainx

I have the same issue when deploying an app on the server, Here is the workaround which works for me: Just add NODE_ENV=production as environment variables on you're a server. I have also add some other environment variables on the root directory (also in web folder): SHOPIFY_API_KEY, SHOPIFY_API_DECRET, HOST, SHOP, SCOPES and it works fine for me now.

is it because the NODE_ENV determine the STATIC_PATH in web/index.js?

 const STATIC_PATH =
   process.env.NODE_ENV === "production"
     ? `${process.cwd()}/frontend/dist`
     : `${process.cwd()}/frontend/`;
ali-faiz-brainx commented 1 year ago

@umutsesen Let me add my understanding on why it works with NODE_ENV=production. Here is our app structure for development environment:

our-project |_ web |_frontend

when we run npm run dev from our root project directory it will look for frontend in ~/our-project/web/frontend folder.

But when we run it on the server we run our index.js from the web directory so now the server is looking for the frontend in ~/our-project/web/web/frontend/dist/index.html file which you can see search for an extra web directory. And you can see a production check in index.js file under the web directory and you see the following check: const STATIC_PATH = process.env.NODE_ENV === "production" ?${process.cwd()}/web/frontend/dist :${process.cwd()}/web/frontend/;

you can see here for production our cwd() is web and we concate that web and then also adding another web for production.

kelreel commented 1 year ago

I got this error again if I make a programmaticaly redirect to the {baseUrl}/api/auth?shop=abc.myshopify.com with invalid session.

thejlyons commented 1 year ago

Saw this for a minute this morning while playing around with a proof of concept app. Surprised this issue is still open, but for my case, I just had mismatched post/get methods.

Calling the api like this:

const response = await appFetch(`/api/report/${reportId}`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' }
});

With the endpoint set up like this:

app.get("/api/report/:reportId", async (_req, res) => { ... });

Fixing the mismatched get/post fixed it for me (app.get -> app.post). This surely doesn't apply to everyone but I thought I'd leave it here.

kelreel commented 1 year ago

I got this error again if I make a programmaticaly redirect to the {baseUrl}/api/auth?shop=abc.myshopify.com with invalid session.

In this case, I did not notice that the middleware function was not called. I replaced shopify.auth.begin with shopify.auth.begin(), the problem has been solved.

// Auth
app.get(shopify.config.auth.path, shopify.auth.begin());
app.get(
  shopify.config.auth.callbackPath,
  shopify.auth.callback(),
)

However, you need to keep in mind that you still need a custom fetch function, exitFrame, etc. It would be useful to explain this more explicitly in the documentation.

cavaestoca commented 1 year ago

Found this error today as well. My fix was about the order of endpoints. If I added the app.get after the ensureInstalledOnShop() it breaks. If I put it before, it works.

image

StepanMynarik commented 1 year ago

My custom embedded app made using the latest Node example (I just switched "useOnlineTokens to true") is unable to create a new session token when opened from the official Shopify mobile app both on Android and iOS.

So the users of the app have to first visit the app from a browser and only then can they use my app from the Shopify app.

I also saw the error mentioned in this task in the console so I hope it is the cause of my issue as well.

MohammedKhalidLimesharp commented 1 year ago

Any update?

PuyaYavari commented 1 year ago

Ok, we had the same issue. We upgraded all of our packages and tried almost everything and nothing worked. We were prepared to add a rule to our CloudWatch to ignore this error. Before that, I decided to do a final investigation on this.

I first looked for the place where this error is being logged and that is here. As you can see there is the condition if (typeof req.query.shop !== 'string') so I added a new middleware before the ensureInstalledOnShop() that logs all the requests that do not pass this condition. image

And we got very unexpected results. The requests that caused this problem were very random! image image image

We don't know what exactly are these, these can be bots or attacks on merchant stores, but anyway, this had to be taken care of. How we took care of this problem was to have a '/home' page (for us instead of index.jsx) and append '/home' to App URL on the App setup and finally change the '/' to '/home/\' for ensureInstalledOnShop() middleware. image Untitled

And this got rid of our problem.

umutsesen commented 1 year ago

If you send a request to a non-existent endpoint, this error is also triggered.

For instance, due to a typo, I spent 3 hours troubleshooting.

The correct endpoint is /api/sizecharts/save while I was mistakenly trying to send requests to /api/sizechart/save.

github-actions[bot] commented 12 months ago

This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days.

paulorivera27 commented 11 months ago

not stale

github-actions[bot] commented 9 months ago

We're labeling this issue as stale because there hasn't been any activity on it for 60 days. While the issue will stay open and we hope to resolve it, this helps us prioritize community requests.

You can add a comment to remove the label if it's still relevant, and we can re-evaluate it.

danieltroger commented 8 months ago

Still an issue for us. We've never had any problems with auth when testing ourselves (on multiple stores, accounts, browsers, etc).

The reviewer added screen recordings of typical auth failures and our log contains

shopify-app/INFO] Running validateAuthenticatedSession
[shopify-app/INFO] Request session has a valid access token | {shop: test-singular.myshopify.com}
[shopify-app/INFO] Running ensureInstalledOnShop
[shopify-app/ERROR] ensureInstalledOnShop did not receive a shop query argument | {shop: undefined}
[shopify-app/INFO] Running ensureInstalledOnShop
[shopify-app/ERROR] ensureInstalledOnShop did not receive a shop query argument | {shop: undefined}
[shopify-app/INFO] Running ensureInstalledOnShop
[shopify-app/ERROR] ensureInstalledOnShop did not receive a shop query argument | {shop: undefined}
[shopify-app/INFO] Running validateAuthenticatedSession

But we can't reproduce it :/

curiouscrusher commented 7 months ago

For anyone who runs into this issue even with the recent CLI / Express package fixes, make sure you check your build process and/or Dockerfile and ensure you're setting NODE_ENV=production. If the NODE_ENV is anything else during build-time then Vite won't package the frontend assets correctly and you'll end up trying to call the HMR assets which will trip the ensureInstalledOnShop

concman commented 6 months ago

@curiouscrusher Hey there, I've added NODE_ENV=production to my env file, when I run the Shopify App Deploy, but still I can't open my app from Shopify admin dashboard. Here's what I've done and what occurred the issue:

This app can’t load due to an issue with browser cookies. Try enabling cookies in your browser, switching to another browser, or contacting the developer to get support.

Here are my logs:

OR[shopify-app/ERROR] ensureInstalledOnShop did not receive a shop query argument | {shop: undefined} INFO[shopify-api/INFO] Creating new session | {shop: lookfor-dev.myshopify.com, isOnline: false} INFO[shopify-api/INFO] Registering webhooks | {shop: lookfor-dev.myshopify.com} INFO[shopify-app/INFO] Running ensureInstalledOnShop INFO[shopify-app/INFO] App is installed and ready to load | {shop: lookfor-dev.myshopify.com} INFO[shopify-app/INFO] Running validateAuthenticatedSession INFO[shopify-app/INFO] Session was not valid. Redirecting to /api/auth?shop=lookfor-dev.myshopify.com | {shop: lookfor-dev.myshopify.com}