From c0fd84ba539086d9ed320832f7eba7ef89ba062a Mon Sep 17 00:00:00 2001 From: newaeonweb Date: Wed, 30 Dec 2020 10:12:17 -0300 Subject: [PATCH] added cors headers --- main.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.js b/main.js index fb94041..3956cf7 100644 --- a/main.js +++ b/main.js @@ -54,6 +54,13 @@ var http = require('http'); // socket for sending data to the printer const Net = require('net'); +// cors option +rest.use(function(res, next) { + res.header("Access-Control-Allow-Origin", "http://localhost:3000"); // use your own domain + res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); + res.header("Access-Control-Allow-Credentials", true) + next(); +}); // Main rest.get('/', function(req, res) {