Assuming this package.json, we could pimp out foo.js to work like so:
const express = require('express');
const cors = require('cors');
var app = express();
app.use(cors());
app.options('*', cors());
app.get('/', (req, res) => res.send('Hello World'));
app.listen(4000, function() { console.log('up and running!'); });
Note that whenever you make changes to this file that you must stop and restart the server for your changes to take effect. Ctrl-C stops the running server.
No comments:
Post a Comment