/node-express-sequelize-postgresql

Src: https://bezkoder.com/node-express-sequelize-postgresql/

Primary LanguageJavaScript

node-express-sequelize-postgresql

Src: https://bezkoder.com/node-express-sequelize-postgresql/

After cloning repo, run the following command (in project folder):

  • node server.js

  • open browser tab to localhost:8080

The following table shows overview of the Rest APIs that will be exported:

*Methods Urls Actions

  • GET api/tutorials get all Tutorials
  • GET api/tutorials/:id get Tutorial by id
  • POST api/tutorials add new Tutorial
  • PUT api/tutorials/:id update Tutorial by id
  • DELETE api/tutorials/:id remove Tutorial by id
  • DELETE api/tutorials remove all Tutorials
  • GET api/tutorials/published find all published Tutorials
  • GET api/tutorials?title=[kw] find all Tutorials which title contains 'kw'

Troubleshooting:

  • If your project works on localhost:// + ${PORT} (specifications in server.js file), see below comment & response from bezkoder at the bottom of this page:

"pullakissa April 8, 2020 at 8:40 am Thank you so much for these tutorials, bezkoder! I am a newbie in fullstack, but I followed this guide for back-end and this (https://github.com/bezkoder/react-crud-web-api) for front-end. Everything is working great on localhost.

However, when I try to access the site from local area network or internet, the back-end connection does not seem to work due to CORS. My web browser console prints this error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8080/api/tutorials. (Reason: CORS request did not succeed).

I have looked through hours of different tutorials, but I still seem to get the same error. Could you please help me? 🙂"


SOLUTION:

"bezkoder April 8, 2020 at 10:23 am Hi, just comment (disable) this line:"

app.use(cors(corsOptions));