DEV Community

Pere Sola
Pere Sola

Posted on

Solve CORS error in express server

  • Install cors library: npm i cors
  • Add the following code:
const express = require("express")
var cors = require("cors")

const app = express()

app.use(cors())
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay