As a continuation of discussion github #7845 …
I tried to prefix all strapi routes with /api in order to be able to isolate them in upstream server (for the following example I didn’t isolate anything). So, I modified the server config as follows:
// modified server config
module.exports = ({ env }) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
url: "/api", // <-- added prefix
admin: {
auth: {
secret: env('ADMIN_JWT_SECRET', 'replaced'),
},
},
});
Trying to access the root, then the admin panel (the button correctly directed to/api/admin
) I got this:
Project information
┌────────────────────┬──────────────────────────────────────────────────┐
│ Time │ Sun Oct 11 2020 10:48:14 GMT+0000 (Coordinated … │
│ Launched in │ 2095 ms │
│ Environment │ development │
│ Process PID │ 20488 │
│ Version │ 3.2.3 (node v12.18.3) │
│ Edition │ Community │
└────────────────────┴──────────────────────────────────────────────────┘
Actions available
To manage your project 🚀, go to the administration panel at:
http://localhost:1337/api/admin
To access the server ⚡️, go to:
http://localhost:1337/api
[2020-10-11T10:48:25.090Z] debug GET index.html (23 ms) 200
[2020-10-11T10:48:25.173Z] debug GET /api/assets/images/logo_login.png (2 ms) 404
[2020-10-11T10:48:25.336Z] debug GET /favicon.ico (0 ms) 200
[2020-10-11T10:48:26.617Z] debug GET /api/admin (3 ms) 200
[2020-10-11T10:48:26.695Z] debug GET /admin/runtime~main.9279ceea.js (4 ms) 404
[2020-10-11T10:48:26.696Z] debug GET /admin/main.081d5ad3.chunk.js (3 ms) 404
Without that /api
prefix everything works fine, but with it looks like subresources inside administration panel are stil requested with unprefixed url. I tried to retreive directly the /admin/runtime~main.9279ceea.js
url with /api
prefix and it works. Did I do something wrong? It looks like things are mixed up here… If I try to isolate the /api
route in upstream it gives:
[2020-10-11T11:48:07.765Z] debug GET /admin (2 ms) 404
PS - I just pasted my latest question from github here as advised. This markdown editor is awesome, is it open source?