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

118
Views
Cannot parse Access-Control-Allow-Headers response header field in preflight response heroku

I deployed my backend on Heroku and my frontend on Netlify

this my index page of my server even after using app.use(cors()) nothing change

import express from 'express';
import dotenv from 'dotenv';
import cors from 'cors';

import connectDB from './config/dbConnection.js';
import URLRoutes from './routes/urlRoutes.js';

dotenv.config({ path: './config/config.env' });

connectDB();

const app = express();

app.use(express.json({ extended: false }));

app.use((req, res, next) => {
  res.header('Access-Control-Allow-Origin', '*');
  res.header(
    'Access-Control-Allow-Headers',
    'Origin, X-Requested, Content-Type, Accept Authorization'
  );
  if (req.method === 'OPTIONS') {
    res.header('Access-Control-Allow-Methods', 'POST, PUT, PATCH, GET, DELETE');
    return res.status(200).json({});
  }
  next();
});

app.get('/', (req, res) => {
  res.send('Hello to Shortly API');
});
app.use('/', URLRoutes);

app.listen(
  process.env.PORT,
  console.log(`Server running on ${process.env.PORT}...`)
);

enter image description here

please feel free to correct any fault .............................................................

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!