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

159
Views
using cors still it show cors error in node app

I'm using cors in my server like this

app.js

const app = require('express')();
const express = require('express');
const messageRoutes = require('./routes/messageRoutes');
const cors = require('cors');
app.use(cors());
app.use(express.json())
app.use('/api/msg',messageRoutes);
app.get('/', (req, res) => {
    res
      .status(200)
      .send('Hello server is running')
      .end();
  });
module.exports=app;

server.js

const app = require("./app");
const dotenv = require("dotenv");
const connectDatabase = require('./database.js');
// dotenv.config({path:'./config.env'});
connectDatabase();
const PORT = process.env.PORT || 4101;
app.listen(PORT);

this is a post request from plain vanilla javascript

 let _data = {
        message,
        sender
    }
    await fetch('https://profoliobackend.herokuapp.com/api/msg/sendmessage', {
        method: 'POST',
        headers: {
                'Content-Type': 'application/json'
        },
        body: JSON.stringify(_data),
    }).then((res) => {
        console.log("thanks for feedback");
    }).catch((e) => {
        console.log(e);
    })

still I'm getting cors issue. I'm using express and node js as backEnd and vanilla javascript as frontend.

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!