Skip to content
Snippets Groups Projects
Commit 2a1c0661 authored by Rolf Niepraschk's avatar Rolf Niepraschk
Browse files

more "Access-Control" header parameter (for nodejs 14)

parent d0815a68
Branches
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ var pkg = require('./package.json');
var cfg = {
VERSION: pkg.version,
DATE: '2020-10-29',
DATE: '2020-12-02',
RELAY_PORT: 55555,
WEBSOCKET_PORT: 9001,
DEFAULT_EXEC_TIMEOUT: 60000, // msec
......
{
"name": "relayServer",
"version": "14.0.1",
"version": "14.1.0",
"description": "Nodejs-based http server for measurement tasks",
"main": "relayServer.js",
"directories": {
......
......@@ -24,6 +24,7 @@ function sendResponse(pRef, js, _data) {
logger.debug('_data: ', _data);
var data, head = js.Head ? js.Head : {};
logger.debug('OutputType: ', js.OutputType);
// evtl. besser: "pRef.res.setHeader(name, value)"?
if (js.OutputType == 'stream') {
if (!head['Content-Type']) head['Content-Type'] =
'application/octet-stream;charset=ISO-8859-1';
......@@ -34,6 +35,11 @@ function sendResponse(pRef, js, _data) {
data = JSON.stringify(_data) + '\n';
}
head['Access-Control-Allow-Origin'] = '*';
head['Access-Control-Allow-Methods'] =
'GET, POST, OPTIONS, PUT, PATCH, DELETE';
head['Access-Control-Allow-Headers'] =
'accept, authorization, content-type, origin, referer';
head['Access-Control-Allow-Credentials'] = true;
logger.debug('head: ', head);
pRef.res.writeHead(200, head);
pRef.res.end(data);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment