Strapi not working on virgin vps server

System Information
  • Strapi Version: 4.5.5
  • Operating System: Ubuntu 22.04
  • Database: PostgreSQL 8.6.0
  • Node Version: 18.13.0
  • NPM Version: 8.19.3

I can’t use a standard pure VPS to run strapi. After all the actions, the panel on the server becomes available to me, but when I enter the login and password, I see “an error occurred”. There are no error messages in the console.

Here is my complete procedure:

I created my strapi application based on PostgreSQL and created some data types and the data itself. React is used to process data. Everything worked great. I uploaded the React App and the Strapi App on GitHub.
I then set up a VPS server, uploaded my React and Strapi apps from GitHub to the VPS server. I installed nginx. I created a database, which I named the same as on the local computer. Checked that the database is new and empty. Next, I made a copy of the database on the local computer, uploaded it to the server and imported it into postgreSQL. After that, this data actually appeared in the database. Everything is fine.
I then copied everything from the .env file located on the strapi project’s local machine to the starpi folder on the VPS.

Then in the strapi folder: npm i → npm run start.

After that, the authorization window became available to me, but after entering the login / password, I saw an error window. There were no errors in the console. In the “Network” tab, I searched for requests and found one with a strange response.
Requests in order:
/admin/project-type - ok.
/admin/init - ok
/admin/telemetry-properties - 401 Unauthorized
Next, I enter the login-password, after which I see the answers:
/admin/login - ok. Came token
https://api.github.com/repos/strapi/strapi/releases/latest - ok
/admin/info - ok
/admin/users/me/permissions - ok
/admin/users/me - ok
/i18n/locales - the response code is ok, but the response body is missing, and instead of the body I see the inscription “JavaScript must be enabled to run this application”
There are no more requests.

I hope we can solve the problem together and it will help someone else in the future.

There may be a problem with the nginx configuration. It’s configured to redirect to /admin but in a broken /i18n request. I’ll try to fix it now and post here.

With a little fiddling with the nginx configuration, I was able to get into the admin panel, although errors still appear. I’ll try some more config manipulation to fix them.

You need to set the server URL key in the server.js file and rebuild the admin

By default we ship a prebuilt admin panel that is compiled for localhost:1337, by setting the url key you change what is compiled into the react app to know how to contact the Strapi backend.

We cover this in our nginx guides: Nginx Proxying - Strapi Developer Docs

1 Like

Cool! I solved my problem by specifying all used strapi paths in the nginx config file, but your solution seems to be more correct