CORS Origin issues.

January 3, 2024, 20:27

mapijs

I'm trying to host one of my web applications on my raspberry but I keep running into CORS issues. I can reach the web application just fine from my computer, and I can input the url in the adress bar just fine (http:// ipadress :3000/getCards?cardName=dark%20magician ) and I get back the JSON that I'm expecting. But when using the web application itself which should send the request I keep running into CORS Origin issues. I tried: npm installing cors, requering it in my javascript and using app.use('cors') tried to explicitly declare the cors headers in my app.get route tried app.use(cors({ origin: '' })); tried
const corsOptions = {
  origin: 'http://ipadress:3000',
  methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
  credentials: true,
  optionsSuccessStatus: 204,
};

app.use(cors(corsOptions));
But nothing seems to work. these are the response headers in my browser:
GET /getCards?cardName=d undefined
Host: localhost:3000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0
Accept: /
Accept-Language: nl,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate, br
Referer: http://ipadress:3000/
Origin: http://ipadress*:3000
Connection: keep-alive
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
I was hoping someone here might be able to help me who perhaps has run into these issues before.

_krazy.

Try reaching out for help in other servers, as this one might not be that in depth with web servers and such.