Added cors
This commit is contained in:
parent
2144d7ef69
commit
3e06856c70
@ -10,6 +10,7 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"cors": "^2.8.5",
|
||||||
"express": "^4.21.1",
|
"express": "^4.21.1",
|
||||||
"i2c-bus": "^5.2.3",
|
"i2c-bus": "^5.2.3",
|
||||||
"serialport": "^12.0.0"
|
"serialport": "^12.0.0"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import cors from 'cors';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import APOLLO from './apollo.js';
|
import APOLLO from './apollo.js';
|
||||||
@ -13,6 +14,8 @@ export default class Daemon {
|
|||||||
|
|
||||||
this.express = express();
|
this.express = express();
|
||||||
|
|
||||||
|
this.express.use(cors('*'));
|
||||||
|
|
||||||
this.express.get('/api/*', async (req, res) => {
|
this.express.get('/api/*', async (req, res) => {
|
||||||
const cmd = req.params['0'];
|
const cmd = req.params['0'];
|
||||||
res.json(await this.run(cmd));
|
res.json(await this.run(cmd));
|
||||||
|
Loading…
Reference in New Issue
Block a user