I'm just trying to run AdminBro on my docker container with NodeJS and Nginx and I am getting the following errors from the nginx error log:
2021/06/05 07:34:28 [error] 13187#13187: *24 open() "/home/aguero/lasfar/website/admin/frontend/assets/global.bundle.js" failed (2: No such file or directory), client: 172.17.0.1, server: , request: "GET /admin/frontend/assets/global.bundle.js HTTP/1.1", host: "0.0.0.0:8080", referrer: "http://0.0.0.0:8080/admin"
2021/06/05 07:34:28 [error] 13187#13187: *24 open() "/home/aguero/lasfar/website/admin/frontend/assets/app.bundle.js" failed (2: No such file or directory), client: 172.17.0.1, server: , request: "GET /admin/frontend/assets/app.bundle.js HTTP/1.1", host: "0.0.0.0:8080", referrer: "http://0.0.0.0:8080/admin"
2021/06/05 07:34:28 [error] 13187#13187: *26 open() "/home/aguero/lasfar/website/admin/frontend/assets/design-system.bundle.js" failed (2: No such file or directory), client: 172.17.0.1, server: , request: "GET /admin/frontend/assets/design-system.bundle.js HTTP/1.1", host: "0.0.0.0:8080", referrer: "http://0.0.0.0:8080/admin"
2021/06/05 07:34:28 [error] 13187#13187: *26 open() "/home/aguero/lasfar/website/admin/frontend/assets/components.bundle.js" failed (2: No such file or directory), client: 172.17.0.1, server: , request: "GET /admin/frontend/assets/components.bundle.js HTTP/1.1", host: "0.0.0.0:8080", referrer: "http://0.0.0.0:8080/admin"
The web page does not show any error, but is blank.
admin.js:
// ============================================
// Admin Bro
const AdminBro = require('admin-bro')
const AdminBroExpress = require('@admin-bro/express')
const adminBro = new AdminBro({
databases: [],
rootPath: '/admin',
})
adminBro.watch()
const router = AdminBroExpress.buildRouter(adminBro)
// ============================================
// Server
const express = require("express");
const server = express();
server
.use(adminBro.options.rootPath, router)
.listen(3000, () => console.log("Server started"));
admin.js is under /home/aguero/lasfar/website/nodejs
nginx.conf:
user aguero;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
server {
listen 0.0.0.0:80 default_server;
location /admin {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
sendfile on;
keepalive_timeout 65;
}
There are more locations on the nginx.conf file, but they are in totally different paths so I removed them for simplicity.
I installed NodeJS with the setup_16.x script and APT. The packages were installed with:
npm install tslib
npm i admin-bro @admin-bro/express express express-formidable
I am mapping the port 80 from the container to the host's 8080 port.
Any idea why these errors are appearing? I can provide more info, if necessary.
To me this forward slash (/) in the proxy_pass in ngnix.config resulted in the bug. Assuming you have your express app running on port 8000 and adminBro/adminJs is accessible by 8000/admin