diff --git a/package.json b/package.json index f42641e..f66f62b 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "author": "", "license": "MIT", "dependencies": { + "cors": "^2.8.5", "express": "^4.21.1", "i2c-bus": "^5.2.3", "serialport": "^12.0.0" diff --git a/src/daemon.js b/src/daemon.js index ea9c600..d85ffc4 100644 --- a/src/daemon.js +++ b/src/daemon.js @@ -1,3 +1,4 @@ +import cors from 'cors'; import express from 'express'; import path from 'path'; import APOLLO from './apollo.js'; @@ -13,7 +14,9 @@ export default class Daemon { this.express = express(); - this.express.get('/api/*', async (req, res) => { + this.express.use(cors('*')); + + this.express.get('/api/*', async (req, res) => { const cmd = req.params['0']; res.json(await this.run(cmd)); });