Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Unable serve bull monitor with http.createServer #79

Open
weilinzung opened this issue Sep 30, 2023 · 4 comments
Open

Unable serve bull monitor with http.createServer #79

weilinzung opened this issue Sep 30, 2023 · 4 comments

Comments

@weilinzung
Copy link
Contributor

weilinzung commented Sep 30, 2023

Hello, I am trying to add a bull monitor to my existing Express app, but when I try to hit http://localhost:3000/monitor it gives me the unable to find route error. Here is my setup, please guide me on what the issue may be.

express.ts

const app = express();

app.use([
helmet(), => this middleware gave the issue...
cors()
]
);

monitor.init().then(() => {
  app.use('/monitor', monitor.router);
});

app.use('/', mainRoutes);

export default app;

main.ts

import http from 'http';
import app from './express';

const server = http.createServer(app);
server.listen(3000);
@weilinzung
Copy link
Contributor Author

I just figured out it is because of the helmet middleware

Refused to load the script 'https://cdn.jsdelivr.net/npm/@bull-monitor/[email protected]/build/main.js' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

@weilinzung
Copy link
Contributor Author

Is possible to allow those resource files loaded from the package? so we can compile them as part of our app?

@s-r-x
Copy link
Owner

s-r-x commented Oct 2, 2023

Is possible to allow those resource files loaded from the package? so we can compile them as part of our app?

nope.

i'll try to look into it. you can add { contentSecurityPolicy: false } into your helmet config as a bandaid

@weilinzung
Copy link
Contributor Author

Is possible to allow those resource files loaded from the package? so we can compile them as part of our app?

nope.

i'll try to look into it. you can add { contentSecurityPolicy: false } into your helmet config as a bandaid

I actually did the way below and is working locally, but the entire app(all routes) gets 504 errors once it is deployed to Google Cloud Run.

  helmet({
    contentSecurityPolicy: {
      useDefaults: true,
      directives: {
        'script-src': ["'self'", 'cdn.jsdelivr.net']
      }
    }
  }),

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants