Open carbonsoda opened 3 years ago
@carbonsoda
app.use(helmet({
contentSecurityPolicy: {
useDefaults: true,
directives: {
'connect-src': [`https://${clientOriginUrl}`, `https://${domain}`], // allow websocket connections to Auth0 domain
'frame-src': [`https://${domain}`], // don't allow this site to be framed
'img-src': ["'self'", 'data:', 'https://s.gravatar.com', 'https://i0.wp.com/', 'https://i2.wp.com/', 'https://avatars.githubusercontent.com/'],
},
},
}));
At the moment we found that while the above loads the page, it generates this error:
apiClient.js:38 Refused to connect to 'https://scribblering-wip.herokuapp.com/api/user/create' because it violates the following Content Security Policy directive: "connect-src https://undefined https://carbonsoda.us.auth0.com".
In the code it's referring to clientOriginUrl
which in the auth0 setup guide they set it to the front-end client's port localhost:3000
, and how it's worked before. For now I'll roll back to the initial CSP until we tease this out.
Turns out, create-react-app takes liberties to embed a particular script into the page, which makes setting CSP tricky.
(from Create React App > Documentation > Advanced Configuration)
So, we can have that set to false, and then set the directives appropriately.
Alternatively, it can just error out, but that doesn't seem as nice.
_Originally posted by @mcab in https://github.com/carbonsoda/scribbler/pull/12#discussion_r629828175_