Created
July 23, 2020 19:41
-
-
Save asadbek064/ec79d1a275efb7f8968ed8082eb0f077 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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