• Stars
    star
    132
  • Rank 274,205 (Top 6 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created about 10 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

CLI to add a good default CORS configuration to CouchDB

Add CORS to CouchDB Build Status

Greenkeeper badge

Summary

CouchDB doesn't come with CORS enabled by default. This is a problem for libraries like PouchDB, which depend on being able to access CouchDB no matter what URL it's being served from. This script fixes that.

Usage

You need to have Node.js and NPM installed. Then do:

npm install -g add-cors-to-couchdb
add-cors-to-couchdb

Or if it is a remote database:

add-cors-to-couchdb http://me.iriscouch.com -u myusername -p mypassword
Ubuntu - special instructions

On 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:

sudo apt-get install nodejs-legacy

What it does

This script will simply add some generic CORS configuration to your CouchDB. You could also do it yourself trivially using curl:

HOST=http://adminname:password@localhost:5984 # or whatever you got

curl -X PUT $HOST/_config/httpd/enable_cors -d '"true"'
curl -X PUT $HOST/_config/cors/origins -d '"*"'
curl -X PUT $HOST/_config/cors/credentials -d '"true"'
curl -X PUT $HOST/_config/cors/methods -d '"GET, PUT, POST, HEAD, DELETE"'
curl -X PUT $HOST/_config/cors/headers -d '"accept, authorization, content-type, origin, referer, x-csrf-token"'

You can always change the configuration later by simply going to http://localhost:5984/_utils/config.html and updating the values. However, these default options are good for getting up and running.

CouchDB 2.0+ instructions

This modules automatically detects CouchDB 2.0 and should do the right thing. But in case you need to configure CORS on a per-node basis, do:

curl -X GET $HOST/_membership

to see the list of available nodes, then do e.g.:

curl -X PUT $HOST/_node/[email protected]/_config/httpd/enable_cors -d '"true"'
curl -X PUT $HOST/_node/[email protected]/_config/cors/origins -d '"*"'
curl -X PUT $HOST/_node/[email protected]/_config/cors/credentials -d '"true"'
curl -X PUT $HOST/_node/[email protected]/_config/cors/methods -d '"GET, PUT, POST, HEAD, DELETE"'
curl -X PUT $HOST/_node/[email protected]/_config/cors/headers -d '"accept, authorization, content-type, origin, referer, x-csrf-token"'

More Repositories

1

pouchdb

🦘 - PouchDB is a pocket-sized database.
JavaScript
16,664
star
2

pouchdb-server

CouchDB-compatible server built on PouchDB and Node
JavaScript
947
star
3

upsert

PouchDB plugin for upsert() and putIfNotExists() functions
JavaScript
149
star
4

express-pouchdb

⚠️⚠️⚠️ THIS REPO HAS MOVED ⚠️⚠️⚠️
143
star
5

pouchbase

Server that lets PouchDB applications sync with passwordless logins
JavaScript
97
star
6

geopouch

Spatial plugin from PouchDB extracted and supporting N dimentional coordinates.
JavaScript
85
star
7

collate

Collation functions for PouchDB map/ reduce and search plugins. ( ⚠️ moved to pouchdb core repo ⚠️ )
JavaScript
38
star
8

pouchdb-auth

A PouchDB plug-in that simulates CouchDB's authentication daemon. Includes a users db that functions like CouchDB's.
JavaScript
36
star
9

plugin-seed

Seed project for PouchDB plugins.
JavaScript
36
star
10

GQL

Google Query Language (GQL) interface for PouchDB
JavaScript
36
star
11

npm-browser

npm in your browser. Because why not. (UNMAINTAINED)
JavaScript
34
star
12

pouchdb-fauxton-chrome-extension

Unmaintained: see #17
JavaScript
26
star
13

pouchdb-express-router

An Express submodule with a CouchDB style REST interface to PouchDB.
JavaScript
24
star
14

mapreduce

PouchDB map/reduce plugin ( ⚠️ UPDATE: moved back to PouchDB core ⚠️ )
23
star
15

pouchdb-search

Search plugin for PouchDB.
JavaScript
15
star
16

couchdb-harness

A generalized port of the CouchDB JavaScript test harness.
JavaScript
12
star
17

pouchdb-validation

A PouchDB plug-in that allows you to re-use your CouchDB validate_doc_update functions on the client side.
JavaScript
10
star
18

pouchdb-fauxton-firefox-addon

JavaScript
7
star
19

pouchdb-fauxton-logic

JavaScript
7
star
20

http-pouchdb

MOVED - SEE THE pouchdb-server REPO
6
star
21

now

Small `now` app to quickly set up an in-memory PouchDB Server
5
star
22

pouchdb-security

This has moved to https://github.com/pouchdb/pouchdb-server
5
star
23

pouchdb-size

Adds disk_size to info()'s output for your leveldown backed PouchDB's.
JavaScript
5
star
24

pouchdb-update

A PouchDB plug-in that allows you to re-use your CouchDB update functions on the client side.
JavaScript
4
star
25

pouchdb-fauxton-base

JavaScript
3
star
26

errors

Utils for working with PouchDB-style error objects.
JavaScript
2
star
27

binary-util

Blob shim for PouchDB
JavaScript
2
star
28

pouchdb-extend

Extends method taken from JQuery 1.9.0 for use in PouchDB (DEPRECATED)
JavaScript
2
star
29

pouchdb-wrappers

Makes wrapping PouchDB functions a lot easier.
JavaScript
2
star
30

pouchdb-show

A PouchDB plug-in that allows you to re-use your CouchDB show functions on the client side.
JavaScript
2
star
31

ajax

Ajax module as used in PouchDB
JavaScript
1
star
32

couchdb-objects

Aids in the construction of JSON objects as used by CouchDB.
JavaScript
1
star
33

sublevel-pouchdb

Fork of level-sublevel with ony the subset of the API that PouchDB uses.
JavaScript
1
star
34

dashboard

JavaScript
1
star
35

pouchdb-bulkdocs-wrapper

Helper function that makes wrapping bulkDocs using pouchdb-wrappers easier.
JavaScript
1
star
36

pouchdb-plugin-error

A PouchDB-like error object, for use by plug-ins.
JavaScript
1
star
37

pouchdb-list

A PouchDB plug-in that allows you to re-use your CouchDB list functions on the client side.
JavaScript
1
star
38

pouchdb-bug-helper

Make awesome reproducable bug reports for PouchDB
HTML
1
star