dcSpark/carp

Add CORS to webserver.

Closed this issue · 3 comments

Hi,

I currently use the carp webserver server behind a nginx reverse proxy. Due to the fact that express doesn't do well without the CORs package even if specified in the nginx config. I have to add it myself everytime I do a fork sync to a new release.

I was wondering if you guys would be willing to add it, if I submitted a simple PR to include cors in the carp webserver server.

Below are two files where the change would happen, package.json to include cors and its types and in the index.ts to pull it in and have express recognize it.

https://github.com/onchainapps/carp/blob/7c21ca5810fae78bc61492022ff8717feac3fa18/webserver/server/package.json#L43
https://github.com/onchainapps/carp/blob/7c21ca5810fae78bc61492022ff8717feac3fa18/webserver/server/package.json#L47

https://github.com/onchainapps/carp/blob/7c21ca5810fae78bc61492022ff8717feac3fa18/webserver/server/app/index.ts#L11

Thank you.
Mike

Hi @bakon11
Thank you for your inquiry. On first glance all looks good but let me talk to other team members and product owner.

Best Regards
Greg

Hi @bakon11
I created docker image with your code: https://github.com/dcSpark/carp/tree/add-cors When I ran doesn't work properly - server doesn`t respond to requests and looks like connection is hanging. How you are configuring CORS settings with this module?

Ok I found issue - should be app.use(cors()); instead of app.use(cors);