Deploy Shopify App in Cloudways - Remix Template

89 Views Asked by At

Good day, everyone!

I have a question regarding Shopify App deployment (remix template)

I know that I can deploy it in either Heroku and Fly.io.
And from what I read in the documentation, It possible to deploy it in other hosting services.

So, right now I am trying to deploy it in Cloudways. But the problem now is that for some reason it is trying to access the default index.php file in Cloudways.

Other parts of the app is working like the following:

  • example.com/auth/login it works!
  • example.com/auth/callback it works!
  • example.com/ it does not work ☹️

Which is why I find it weird, why it does not work when the app itself is just an express app calling build/index.js. I checked my pm2 logs, whenever I try to visit the site, it will throw an error mentioning Error: No route matches URL "/index.php".

Do note that the index.php is already there when I created an application in Cloudways.


For more information, here are some code snippets:

server.mjs

import { createRequestHandler } from "@remix-run/express";
import express from "express";

// notice that the result of `remix build` is "just a module"
import * as build from "./build/index.js";

// port is 4007
const port = process.env.PORT || 4007;

const app = express();
app.use(express.static("public"));

// and your app is "just a request handler"
app.all("*", createRequestHandler({ build }));

app.listen(port, () => {
  console.log(`App listening on http://localhost:${port}`);
});

.htaccess

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)?$ http://localhost:4007/$1 [P,L]

I would highly appreciate it, if you guys can tell me what am I missing with this? Can I really not deploy my app in Cloudways?

I tried contacting Cloudways support, they mentioned:

We have a custom stack so it does not support some application types such as python based frame works on ruby on rails and same goes for Shopify, so it cannot work as custom, however, you can do one thing you can launch a direct server on our parent company DigitalOcean and there you can use this custom app.

Deploying to other hosting services isn't an option for me, as it is not really cost-effective on my end.

If it is really impossible, any advice on how to approach this problem?

1

There are 1 best solutions below

0
John Doe On

I have found a solution for this. For anyone trying to deploy their shopify remix app, you guys can just do the following:

Just add DirectoryIndex disabled to your .htaccess file. This should prevent it from trying to access the default index.php file.

DirectoryIndex disabled
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)?$ http://localhost:4007/$1 [P,L]

If you guys have a better solution than this, please feel free to post it here.