Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Server is loading forever as I use the following code for server.js

I have used this code in server.js file and the main code in app.js in folder called website. when i run localhost using node server.js in terminal and run http://localhost:3000 in browser, it is loading forever with no stopping.

const bodyParser=require('body-parser');
const express=require('express');
const app=express();
/*dependencies*/
//Here we are configuring express to use body-parser as middle-ware.
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
//cors for cross origin allowance
const cors=require('cors');
app.use(cors);
//making a local server
const port= 3000;
const server = app.listen(port, ()=>{console.log(`running on localhost: ${port}`)});
app.use(express.static('website'));

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Remove the CORS module. You probably don’t need it and its the reason for the infinite loading. If you need it, you should probably search for a different module.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading