You have to override some webpack config that comes with create-react-app and add "X-Frame-Options": "SAMEORIGIN"
.
But in CRA, you can't do that directly with a webpack.config.js
. You gotta use a package that rewires the way CRA start / build your app. Here are the rewiring packages you can use:
- react-app-rewired (CRA v1)
- customize-cra or rescript (CRA v2)
- craco (CRA v3)
To know which CRA version you used, you can roughly follow the react-scripts
version in your package.json
.
craco
I succeeded with this craco config!!! In craco.config.js:
module.exports = {
webpack: {
headers: {
'X-Frame-Options': 'Deny'
}
}
}
(I tested by scanning in Burpsuite; the Frameable Response issue was gone.)
Reference: How to set alias path via webpack in CRA (create-react-app) and craco?
react-app-rewired
I THINK you could try this, BUT I haven't tested it. In config-overrides.js:
module.exports = {
devServer: function(configFunction) {
return function(proxy, allowedHost) {
const config = configFunction(proxy, allowedHost)
config.headers = {
'X-Frame-Options': 'Deny'
}
return config
}
}
}
Reference: Create React App adding CORS header
*I may have loosely gotten the versions wrongly, please correct if so.