DEV: Ensure ember-cli rake theme:qunit works with CSP enabled (#16541)

- Make proxy pass `x-forward...` headers, so that Rails can set the host/port correctly in the csp
- Make `testem.js` available on a route which is within the app's default CSP
This commit is contained in:
David Taylor 2022-04-22 16:59:45 +01:00 committed by GitHub
parent e0d7431292
commit 794d2dabf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -78,8 +78,20 @@ if (process.argv.includes("-t")) {
module.exports.proxies[`/*/theme-qunit`] = {
target: `${target}${testPage}`,
ignorePath: true,
xfwd: true,
};
module.exports.proxies["/*/*"] = { target };
module.exports.proxies["/*/*"] = { target, xfwd: true };
module.exports.middleware = [
function (app) {
// Make the testem.js file available under /assets
// so it's within the app's CSP
app.get("/assets/testem.js", function (req, res, next) {
req.url = "/testem.js";
next();
});
},
];
} else if (shouldLoadPluginTestJs()) {
// Running with ember cli, but we want to pass through plugin request to Rails
module.exports.proxies = {

View File

@ -29,7 +29,7 @@
</style>
<%- end %>
<%- if params['testem'] %>
<script src="/testem.js"></script>
<script src="/assets/testem.js"></script>
<%- end %>
</head>
<body>