Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
El módulo Node JS CORS no configura el encabezado expreso Access-Control-Allow-orgin
I am trying to create api and fetch it from front but the "Access-Control-Allow-Origin" is not allowing me.

Traté de resolver el problema pero todavía me muestra el problema.

esta es la parte delantera

Lo busqué por el método GET pero no funciona

 const api = "http://localhost:3000/api/posts/"; const base_api = "http://localhost:3000/"; console.log(api); window.onload = () => { getPost(); }; const getPost = () => { fetch( api , { method: "GET", }) .then((response) => { return response.json(); }) .then((data) => { buildPost(data); console.log(data); }); }; const buildPost = (blogPost) => { console.log(blogPost);

*esta es la parte express

Usé el "*" que todavía muestra el error. que mas solucion podria ser

 const express = require("express"); const app = express(); const Post= require("./api/models/posts"); const postsData= new Post(); app.use((req, res, next) =>{ res.setHeader("Access-Control-Allow-Orgin","*" ) next(); }) app.use(express.json()); app.use ('/uploads', express.static('uploads')) app.get("/api/posts", (req, res)=>{ res.status(200).send(postsData.get()) }); app.get("/api/posts/:post_id", (req, res)=>{ const postId = req.params.post_id; const foundedPost= postsData.getEachData(postId); }); app.listen(3000, ()=> console.log("Listening on

http://localhost:3000/"))

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!