1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00

Fix empty X-CSRFToken bug

This commit is contained in:
vrde 2015-06-16 19:28:21 +02:00
parent dfd4435e27
commit bd2be63341
2 changed files with 11 additions and 3 deletions

View File

@ -76,7 +76,10 @@ class Requests {
request(verb, url, options) { request(verb, url, options) {
options = options || {}; options = options || {};
let merged = this._merge(this.httpOptions, options); let merged = this._merge(this.httpOptions, options);
this.httpOptions.headers['X-CSRFToken'] = getCookie('csrftoken'); let csrftoken = getCookie('csrftoken');
if (csrftoken) {
merged.headers['X-CSRFToken'] = csrftoken;
}
merged.method = verb; merged.method = verb;
return fetch(url, merged) return fetch(url, merged)
.then(this.unpackResponse) .then(this.unpackResponse)

View File

@ -12,14 +12,19 @@ app.use(baseUrl + 'static/js', express.static(__dirname + '/build/js'));
app.use(baseUrl + 'static/img', express.static(__dirname + '/build/img')); app.use(baseUrl + 'static/img', express.static(__dirname + '/build/img'));
app.use(baseUrl + 'static/css', express.static(__dirname + '/build/css')); app.use(baseUrl + 'static/css', express.static(__dirname + '/build/css'));
app.use(baseUrl + 'static/fonts', express.static(__dirname + '/build/fonts')); app.use(baseUrl + 'static/fonts', express.static(__dirname + '/build/fonts'));
app.use(baseUrl + 'static/thirdparty/', express.static(__dirname + '/node_modules')); app.use(baseUrl + 'static/thirdparty', express.static(__dirname + '/node_modules'));
app.get(/.*/, function(req, res) { app.get(/.*/, function(req, res) {
console.log('%s %s', req.method, req.path);
res.sendFile(__dirname + '/build/index.html'); res.sendFile(__dirname + '/build/index.html');
}); });
if (require.main === module) { if (require.main === module) {
app.listen(process.env.PORT || 4000); var port = process.env.PORT || 4000;
console.log('Starting Onion server on port', port,
'baseUrl is set to', baseUrl);
app.listen(port);
} }
module.exports.app = app; module.exports.app = app;