diff --git a/js/utils/requests.js b/js/utils/requests.js index 1eee67ab..20e8ef65 100644 --- a/js/utils/requests.js +++ b/js/utils/requests.js @@ -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) diff --git a/server.js b/server.js index ef590a70..156b22f3 100644 --- a/server.js +++ b/server.js @@ -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;