I have made a Remix app and i want to deploy it to me plesk server but i can't figure out what to do.
I have installed node.js but can't figure out the application startup file or what it is i exactly need to do.
Do i need to have 2 domains? one for the client side and one for the server side?
Is there anybody who already have done this and what did you do to make it work?
Hi, this is a bit tricky, but you can do it by following next steps:
I suppose you already have Node set in your Plesk.
1) Remix use some adapters in order to ran your SSR app , the default one is
Remix App Server. in your case you need to use
@remix-run/express
adapter you can find more info about this reading this part
Runtimes, Adapters, Templates, and Deployment and specially this part
Templates and Stacks.
So basically you need to setup your app using this command:
Bash:
npx create-remix@latest --template remix-run/remix/templates/express
this will create a new
server.js
file inside your root project. This is just setting up your express backend app.
2) Be sure you have the
start
command set like this
"start": "cross-env NODE_ENV=production node ./server.js",
inside your
package.json
file.
3) ran
npm run build
this will generate a build folder for later copy to plesk.
4) create
loader.cjs
file inside your project root same place with
server.js
file and add this content to it:
JavaScript:
async function loadApp() {
await import('./server.js');
}
loadApp();
more info about this file you can find on this
thread.
5) Set your Plesk node App like this:
6 ) copy all your project files , including
build
folder,
server.js
and
loader.cjs
to your
/httpdocs
domain folder.
7) Execute
npm install
and
npm build
from Run
Node.js
commands tab:
8) Restart your Node App and check your domain if now works.