Replies: 1 comment
-
I was able to create the below solution, but it's very hacky. import { injectable } from 'inversify';
import { Application } from 'express';
import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application';
@injectable()
export class ConfigContribution implements BackendApplicationContribution {
configure(app: Application): void {
app.use((req, res, next) => {
res.send('Test');
});
const stack: Array<any> = app._router.stack;
const layer = stack.pop();
for (let i = 0; i < stack.length; i++) {
if (stack[i].name === 'serveStatic') {
stack.splice(i, 0, layer);
break;
}
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to add a custom middleware by creating a plugin. A similar approach to https://github.com/brilliant-code/theia-cookie-auth.
Generated server.js (default) has the following code
application.start
is responsible for loading contributions, and they are loaded after the existing middlewareapplication.use(express.static(...))
.My custom middleware is never executed, because
express.static
return the default HTML page, and stops processing.Any tip on how to insert middleware at the beginning?
version: latest
Beta Was this translation helpful? Give feedback.
All reactions