mirror of
https://github.com/ascribe/onion.git
synced 2024-12-21 17:03:14 +01:00
Fix empty X-CSRFToken bug
This commit is contained in:
parent
dfd4435e27
commit
bd2be63341
@ -76,7 +76,10 @@ class Requests {
|
||||
request(verb, url, options) {
|
||||
options = 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;
|
||||
return fetch(url, merged)
|
||||
.then(this.unpackResponse)
|
||||
|
@ -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/css', express.static(__dirname + '/build/css'));
|
||||
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) {
|
||||
console.log('%s %s', req.method, req.path);
|
||||
res.sendFile(__dirname + '/build/index.html');
|
||||
});
|
||||
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user