Skip to content

Commit b12b50b

Browse files
authored
fix: add Origin header in the proxy so to bypass django CSRF protections (#5591)
Fix the e2e tests that are failing due to the new CSRF protections introduced in Django 4.x. We simply add in the proxy the fake Origin header. Resolves [MAASENG-4353](https://warthogs.atlassian.net/browse/MAASENG-4353)
1 parent e953942 commit b12b50b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

scripts/proxy.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ app.use(
3333
onProxyReq(proxyReq) {
3434
// Django's CSRF protection requires requests to come from the correct
3535
// protocol, so this makes XHR requests work when using TLS certs.
36+
proxyReq.setHeader("Origin", `${process.env.MAAS_URL.replace(/\/$/, "")}`);
3637
proxyReq.setHeader("Referer", `${process.env.MAAS_URL}${proxyReq.path}`);
3738
},
3839
secure: false,

0 commit comments

Comments
 (0)