I'm using AWS with Nodejs and express. The server runs on an ec2 instance with alb. My website tries to connect to another website where the server runs, that's e. g. server.com. When I try to get on the server.com, it shows me the text it should, but if I go on server.com/create-checkout-session, it gives me a 502 Bad Gateway. My website that tries to connect gives out a CORS preflight request error in the console because no "Access-Control-Allow-Origin" header would be present on the requested source. I tried a lot, nothing worked that's why I'm asking.
Here the server.js:
const express = require('express');
const cors = require('cors');
require('dotenv').config({ path: './.env' });
const createCheckoutSession = require('./api//checkout');
const webhook = require('./api/webhook');
const app = express();
const port = 8080;
app.use(express.json({
verify: (req, res, buffer) => req['rawBody'] = buffer,
}));
app.use(cors({ origin: true }));
app.get('/', (req, res) => res.send('hello world'));
app.post('/create-checkout-session', createCheckoutSession);
app.post('/webhook', webhook);
app.listen(port, () => console.log('server listening on port', port));