Mini-Sylar / shopify-app-vue-template

Create a shopify app with node and vue 3
https://shopify-vue-template.vercel.app/
MIT License
59 stars 6 forks source link

Error opening application in production #56

Open isaacgz opened 1 month ago

isaacgz commented 1 month ago

Hi

I used the template with Vue to create my app, but I have the following problem when deploying to production:

1.- The app couldn't be loaded:

6

2.- When I try to open the application I get the following error:

7

I am deploying my application via PM2 on my own server, so I don't know if this is a factor in the error. I look forward to your comments.

Mini-Sylar commented 1 month ago

Hi, can you share some of the logs from PM2?

isaacgz commented 1 month ago

Sure:

imagen

I don't know why when I install the application, the log runs several times

Mini-Sylar commented 1 month ago

That bit is expected, on initial load it performs a few oAuth connections

it seems to fail after a while, someone recently had that issue but that was on dev.

can you confirm the dependencies in the root package.json? I might be able to recreate it

isaacgz commented 1 month ago

Look, this is the package I have in the root

imagen

Mini-Sylar commented 1 month ago

Alright let's do the following,

the redirect URLs must be set properly

let me know if the issue gets resolved

isaacgz commented 1 month ago

Hi, I did everything as you mentioned and nothing works, I still have the same error

Mini-Sylar commented 1 month ago

Hi, Can you try the following :

//index.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();
};

app.use("/api/*", shopify.validateAuthenticatedSession());
// Middleware should come after
app.use("/*", addSessionShopToReqParams);
isaacgz commented 1 month ago

Thanks for answering, mmm no, I had already tried it before and it still shows me the same error, I even have the code like this: imagen

but nothing work's, here we have a video with the error: https://screenshot.click/05-57-31754-74340.webm

isaacgz commented 1 month ago

Another detail is the following: the sessions are not saved in the SQLite database even if the application has been installed in the store. Is there a problem with PM2 and SQLite?

imagen

Mini-Sylar commented 1 month ago

Thanks for answering, mmm no, I had already tried it before and it still shows me the same error, I even have the code like this:

but nothing work's, here we have a video with the error: https://screenshot.click/05-57-31754-74340.webm

Interesting, It seems your app is working

the issue might be with the root shopify.app.toml

Can you show me what that looks like? Be sure to hide sensitive information such as the client_id

Mini-Sylar commented 1 month ago

Another detail is the following: the sessions are not saved in the SQLite database even if the application has been installed in the store. Is there a problem with PM2 and SQLite?

Also out of curiosity, how are you running the app?

isaacgz commented 1 month ago

in my own server, is a windows server

Mini-Sylar commented 1 month ago

RE: Interesting, It seems your app is working

the issue might be with the scopes in the root shopify.app.toml

Can you show me what that looks like? Be sure to hide sensitive information such as the client_id

isaacgz commented 1 month ago

yeap:

imagen

Mini-Sylar commented 1 month ago

Alright, so a few things you need to setup before running the app in production

Step 1

Step 2

In the shopify.app.toml:

[access_scopes]
# Learn more at https://shopify.dev/docs/apps/tools/cli/configuration#access_scopes
scopes = "read_customers,read_orders" # Add the access scopes you need !very important
use_legacy_install_flow = true #You may OMIT THIS

Step 3 Very Very Important

Step 4 Push the changes

Step 5 (Since you're on a VPS) - I've only used linux so windows setup may vary

As always let me know if there are any issues, in order to not conflict the toml files you can create shopify.app.diversified-deal-app.toml for example and use the dev urls

Mini-Sylar commented 2 weeks ago

@isaacgz Has the issue been resolved now?