Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Hello,
I have a 1-click LAMP Droplet (Ubuntu). I’ve installed Node.js on it and I’ve added an express.js application.
With PM2 I made it run successfully on port 3002, if I use sudo pm2 list I can see that is online. I’m trying to reach endpoints on this running express.js app from my React website (which is on the same server), but I get CORS Failed as I see on Network tab(browser inspector window).
My express.js app has cors:
const express = require('express');
var cors = require('cors');
const app = express();
app.use(cors());
app.use(express.json());
And in React, I’m doing the request like this:
await fetch('https://localhost:3002/contacts', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
}).then(response => response.json())
.then(data => {
console.log(data);
}).catch((error) => {
console.log(error);
});
Ubuntu version: 20.04.2 LTS (Focal Fossa) PM2 version: 5.1.2 Node.js version: 16.13.1
Is something that I’m missing?
Thanks alot.
KFSys
1e6b823ea20d4cb189a34a922f5588
a78df6d867e44a458d3e9e23747988
ibrahim
mayricoak
nashurgessa
tumerseyrek
da1d14cd11434cac8303ee43a3cec6
bennyooo
Samiuddin Mohammed
HappyDarkCyanDolphin