javascriptnode.jscontent-management-systemstrapipm2

Strapi - /admin folder not found


So i got an issue while deploying it on the server.

Localhost works fine, however when I open the strapi admin panel on the server, it asks for admin folder which I could not find. Here is the working link to checkout: https://s-dash.ihoops.uz

So i have searched how to skip this error, as the error asks for /admin/runtime~main and /admin/main js files

So, I am building the strapi admin panel with yarn build command, but it is working fine in localhost as I have mentioned earlier. So after building the strapi, in my project folder shows up a folder which's name is build but after I put it to server public_html, the error reveals like it cannot find the find the folder admin. After that, I renamed my build folder to admin to check can it handle the error after all because the <runtime~main> and <main> javascript files are inside of build folder.

After I renamed the folder to admin the strapi admin panel launched but the error type is changed:

Then now, it is asking for /admin/init and /admin/project-type. After I linked process manager to admin panel (pm2) it still stood like this in pending.

/server.js file:

const strapi = require('@strapi/strapi')
strapi().start()

/ecosystem.config.js file:

module.exports = {
  apps: [
    {
      name: 'app',
      script: 'yarn',
      args: 'start-production',
      env: {
        NODE_ENV: 'production'
      }
    },
  ],
};

/package.json file:

"scripts": {
    "develop": "strapi develop",
    "start": "strapi start",
    "build": "strapi build",
    "strapi": "strapi",
    "start-production": "env NODE_ENV=production yarn start",
    "production": "env NODE_ENV=production yarn build"
},

So, I think would be in the hosting in the /config/server.js

module.exports = ({ env }) => ({
  host: env("HOST", "0.0.0.0"),
  port: env.int("PORT", 1337),
  url: env('PUBLIC_URL', 'https://s-dash.ihoops.uz'),
  app: {
    keys: env.array("APP_KEYS"),
  },
  webhooks: {
    populateRelations: env.bool("WEBHOOKS_POPULATE_RELATIONS", false),
  },
});

But when I changed the host url from 0.0.0.0 to my hosting url, localhost stopped working also, but after that i found out the url should exist in the path file so, I added the PUBLIC_URL, however, now localhost except public host also


Solution

  • If you're using Prettier as your code formatter and you have your .htaccess file on your VSCode/project directory, it might help if you check your .htaccess file. On my case, Prettier is messing with my .htaccess file adding a forward slash on the RewriteRule. it's messing with the routing

    I deploy my sites in CLoudways server and I have to create a .htaccess file to route the app to the right destination and Prettier is messing with it. I've been troubleshooting and re-creating the app for 3 days when I see the issue. I want to punch somebody. HAHAHAHHA