adminizer 4.2.0-build.65 → 4.2.0-build.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/Adminizer.js CHANGED
@@ -70,30 +70,33 @@ export class Adminizer {
70
70
  }
71
71
  getMiddleware() {
72
72
  return (req, res, next) => {
73
- // If a routePrefix is configured, only handle requests that match it.
74
73
  try {
75
74
  const prefix = (this.config && this.config.routePrefix) ? String(this.config.routePrefix) : '';
76
75
  const normalizedPrefix = prefix.replace(/\/+/g, '/').replace(/\/+$/g, '');
77
76
  if (normalizedPrefix) {
78
77
  const url = req.url || req.originalUrl || '';
79
- if (!(url === normalizedPrefix || url.startsWith(normalizedPrefix + '/') || url.startsWith('/public'))) {
80
- // Not an admin route — pass to next middleware
78
+ const conditions = [
79
+ url === normalizedPrefix,
80
+ url.startsWith(normalizedPrefix + '/')
81
+ ];
82
+ if (process.env.IS_SAILS === undefined) {
83
+ conditions.push(url.startsWith('/public'));
84
+ }
85
+ if (!conditions.some(condition => condition)) {
81
86
  return typeof next === 'function' ? next() : undefined;
82
87
  }
83
88
  }
84
89
  }
85
90
  catch (e) {
86
- // If anything goes wrong while checking, fall back to handling the request
91
+ // fall back to handling the request
87
92
  }
88
93
  this.app(req, res, (err) => {
89
94
  if (err) {
90
- // eslint-disable-next-line no-console
91
95
  console.error("Error in Adminizer", err);
92
96
  res.writeHead(500, { 'Content-Type': 'text/plain' });
93
97
  res.end('Internal Server Error');
94
98
  }
95
99
  else {
96
- // If Adminizer didn't handle the route, let the rest of the stack try
97
100
  if (typeof next === 'function') {
98
101
  return next();
99
102
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "adminizer",
3
3
  "type": "module",
4
- "version": "4.2.0-build.65",
4
+ "version": "4.2.0-build.67",
5
5
  "main": "index.js",
6
6
  "exports": {
7
7
  ".": "./index.js",
@@ -17,6 +17,7 @@ export function bindInertia(adminizer) {
17
17
  <script type="module" src="/@vite/client"></script>
18
18
  <script type="module" src="/src/assets/js/app.tsx"></script>
19
19
  <script>window.routePrefix = "${adminizer.config.routePrefix}"</script>
20
+ <script>window.isSails = ${process.env.IS_SAILS ? 'true' : 'false'};</script>
20
21
  `;
21
22
  }
22
23
  else {
@@ -57,11 +58,14 @@ export function bindInertia(adminizer) {
57
58
  });
58
59
  // Route prefix script
59
60
  const routePrefixScript = `<script>window.routePrefix = "${adminizer.config.routePrefix}";</script>`;
61
+ // For Sails JS
62
+ const isSails = `<script>window.isSails = ${process.env.IS_SAILS ? 'true' : 'false'};</script>`;
60
63
  return `
61
64
  ${preloadLinks.join('\n')}
62
65
  ${stylesheets.join('\n')}
63
66
  ${scripts.join('\n')}
64
67
  ${routePrefixScript}
68
+ ${isSails}
65
69
  `;
66
70
  }
67
71
  };
@@ -15,7 +15,8 @@ export default function bindMediaManager(adminizer) {
15
15
  }
16
16
  });
17
17
  // Bind media manager public folder
18
- adminizer.app.use(`/public`, serveStatic(adminizer.config.mediamanager.fileStoragePath));
18
+ if (!process.env.IS_SAILS)
19
+ adminizer.app.use(`/public`, serveStatic(adminizer.config.mediamanager.fileStoragePath));
19
20
  // Bind file icons
20
21
  adminizer.app.use(`${adminizer.config.routePrefix}/fileicons`, serveStatic(path.join(import.meta.dirname, '../fileicons')));
21
22
  }