Skip to content

Instantly share code, notes, and snippets.

@asadbek064
Created July 23, 2020 19:41
Show Gist options
  • Select an option

  • Save asadbek064/ec79d1a275efb7f8968ed8082eb0f077 to your computer and use it in GitHub Desktop.

Select an option

Save asadbek064/ec79d1a275efb7f8968ed8082eb0f077 to your computer and use it in GitHub Desktop.
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const cors = require('cors');
// Allowing Access-Control-Allow-Origin
app.use(cors());
const corsOptions = {
origin: 'http://localhost:4200',
optionsSuccessStatus: 200
};
// BodyParser Middleware
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// CORS Middleware
app.use(cors(corsOptions))
// ROUTES
const recaptcha = require('./app/routes/recaptcha.routes');
app.use('/recaptcha', recaptcha);
// Create a Server
const server = app.listen(3000, function () {
let host = server.address().address
let port = server.address().port
console.log("App listening at http://%s:%s", host, port)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment