#Please help, I'm trying to link my angular app on localhost4200 to my Codespace express server.

2 messages · Page 1 of 1 (latest)

forest hill
#

I keep getting all kinds of CORs and preflight errors that I don't understand. Please see attachments of my error. and the top part of my server code below:

const express = require('express');
const cors = require('cors');
const axios = require('axios');

const app = express();
app.use(cors());
app.use(express.json());
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');

res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
next();
});

brazen folio
#

When you use cross origins the browser send a preflight request (http verb: OPTIONS) to know what the server authorize before sending your request.
The error suggest that the preflight request return a 3XX redirect status which is not allowed for preflight request.

1/ Try to remove the trailing slash in https://vitaminr-studious-fishstick-697wrr5q944f45gq-3000.preview.app.github.dev/api/transcribe/
maybe the server redirect to https://vitaminr-studious-fishstick-697wrr5q944f45gq-3000.preview.app.github.dev/api/transcribe
2/ Check configuration of the server