{"id":13431762,"url":"https://github.com/pouchdb/add-cors-to-couchdb","last_synced_at":"2025-04-09T18:19:13.396Z","repository":{"id":19956108,"uuid":"23222965","full_name":"pouchdb/add-cors-to-couchdb","owner":"pouchdb","description":"CLI to add a good default CORS configuration to CouchDB","archived":false,"fork":false,"pushed_at":"2020-03-16T07:39:21.000Z","size":36,"stargazers_count":134,"open_issues_count":7,"forks_count":17,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-09T18:19:08.095Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pouchdb.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-22T11:22:34.000Z","updated_at":"2025-03-04T08:56:00.000Z","dependencies_parsed_at":"2022-08-26T21:29:33.641Z","dependency_job_id":null,"html_url":"https://github.com/pouchdb/add-cors-to-couchdb","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pouchdb%2Fadd-cors-to-couchdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pouchdb%2Fadd-cors-to-couchdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pouchdb%2Fadd-cors-to-couchdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pouchdb%2Fadd-cors-to-couchdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pouchdb","download_url":"https://codeload.github.com/pouchdb/add-cors-to-couchdb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085325,"owners_count":21045139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T02:01:05.669Z","updated_at":"2025-04-09T18:19:13.377Z","avatar_url":"https://github.com/pouchdb.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","others"],"sub_categories":[],"readme":"Add CORS to CouchDB [![Build Status](https://travis-ci.org/pouchdb/add-cors-to-couchdb.svg?branch=master)](https://travis-ci.org/pouchdb/add-cors-to-couchdb)\n====\n\n[![Greenkeeper badge](https://badges.greenkeeper.io/pouchdb/add-cors-to-couchdb.svg)](https://greenkeeper.io/)\n\n#### Summary\n\nCouchDB doesn't come with [CORS](https://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing) enabled by default. This is a problem for libraries like [PouchDB](http://pouchdb.com), which depend on being able to access CouchDB no matter what URL it's being served from. This script fixes that.\n\n#### Usage\n\nYou need to have [Node.js and NPM](https://nodejs.org) installed. Then do:\n\n```\nnpm install -g add-cors-to-couchdb\nadd-cors-to-couchdb\n```\n\nOr if it is a remote database:\n\n```\nadd-cors-to-couchdb http://me.iriscouch.com -u myusername -p mypassword\n```\n\n##### Ubuntu - special instructions\n\nOn Ubuntu the default Node.js library is called `nodejs` instead of `node` due to a naming conflict. To run on Ubuntu, you'll need to do:\n\n```\nsudo apt-get install nodejs-legacy\n```\n\n#### What it does\n\nThis script will simply add some generic CORS configuration to your CouchDB. You could also do it yourself trivially using `curl`:\n\n```bash\nHOST=http://adminname:password@localhost:5984 # or whatever you got\n\ncurl -X PUT $HOST/_config/httpd/enable_cors -d '\"true\"'\ncurl -X PUT $HOST/_config/cors/origins -d '\"*\"'\ncurl -X PUT $HOST/_config/cors/credentials -d '\"true\"'\ncurl -X PUT $HOST/_config/cors/methods -d '\"GET, PUT, POST, HEAD, DELETE\"'\ncurl -X PUT $HOST/_config/cors/headers -d '\"accept, authorization, content-type, origin, referer, x-csrf-token\"'\n```\n\nYou can always change the configuration later by simply going to [http://localhost:5984/_utils/config.html](http://localhost:5984/_utils/config.html) and updating the values. However, these default options are good for getting up and running.\n\n#### CouchDB 2.0+ instructions\n\nThis modules automatically detects CouchDB 2.0 and should do the right thing. But in case\nyou need to configure CORS on a per-node basis, do:\n\n```bash\ncurl -X GET $HOST/_membership\n```\n\nto see the list of available nodes, then do e.g.:\n\n```bash\ncurl -X PUT $HOST/_node/node1@127.0.0.1/_config/httpd/enable_cors -d '\"true\"'\ncurl -X PUT $HOST/_node/node1@127.0.0.1/_config/cors/origins -d '\"*\"'\ncurl -X PUT $HOST/_node/node1@127.0.0.1/_config/cors/credentials -d '\"true\"'\ncurl -X PUT $HOST/_node/node1@127.0.0.1/_config/cors/methods -d '\"GET, PUT, POST, HEAD, DELETE\"'\ncurl -X PUT $HOST/_node/node1@127.0.0.1/_config/cors/headers -d '\"accept, authorization, content-type, origin, referer, x-csrf-token\"'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpouchdb%2Fadd-cors-to-couchdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpouchdb%2Fadd-cors-to-couchdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpouchdb%2Fadd-cors-to-couchdb/lists"}