CORS issue after upgrading [Dec 29]

:raising_hand_man: ebuyum asked

If it matters

I upgraded version 0.11.29 → 0.83.8 (current latest)

:person_tipping_hand: o1lab replied

Is it just the swagger API request ? or you can call it from say an API Client ?

:raising_hand_man: ebuyum replied

Any API client works fine, postman for example works well

:raising_hand_man: ebuyum replied

But, when trying to use a react app using axios library is when I fail

:person_tipping_hand: o1lab replied

axios has to add extra header for this

could you please search

:raising_hand_man: ebuyum replied

extra header for cors?

:raising_hand_man: ebuyum replied

I’m checking

:raising_hand_man: ebuyum replied

Tried adding ‘Access-Control-Allow-Origin’: ‘*’ to the request headers but didn’t seem to help

:raising_hand_man: ebuyum replied

Checking online suggests using packages such as http-proxy-middleware, but its interesting that something changed during the versions

:man_technologist: pranavxc replied

Update index.js file inside the generated code to enable Cross origin access

```js

const cors = require(“cors”);

(async () => {

const app = require(‘express’)();

const {Noco} = require(“nocodb”);

app.use(

cors({

origin: “*”,

})

);

app.use(await Noco.init({}));

console.log(Visit : localhost:${process.env.PORT}/dashboard)

app.listen(process.env.PORT);

})()

```

:raising_hand_man: ebuyum replied

Ah, ok, interesting

let me try, since I’ve got nocodb deployed on a cloud foundry instance

:raising_hand_man: ebuyum replied

I’m guessing this isn’t exposed to an environment variable?

:man_technologist: pranavxc replied

earlier did it worked with react ?

:raising_hand_man: ebuyum replied

Yeah

:raising_hand_man: ebuyum replied

But this was a really old version

:raising_hand_man: ebuyum replied

Ah, fixed it completely

:raising_hand_man: ebuyum replied

You guys rock, thanks a lot!

:raising_hand_man: ebuyum replied

I’m guessing the nocodb-seed project doesn’t get updated a lot?

I can just use a modified index.js file and still have latest nocodb right?

:man_technologist: pranavxc replied

it’s better to avoid using * - use the domain name you are going to use as origin, refer cors - npm

:man_technologist: pranavxc replied

yes… nocodb is installed as npm module