Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
feat(http): set default headers for browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Nov 11, 2016
1 parent cd7f77d commit 6a21cd0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
"libp2p-ipfs": "libp2p-ipfs-browser",
"./src/core/default-repo.js": "./src/core/default-repo-browser.js",
"./src/core/components/init-assets.js": false,
"fs-pull-blob-store": false,
"glob": false,
"rimraf": false
"./test/utils/temp-repo.js": "./test/utils/temp-repo-browser.js",
"stream": "readable-stream"
},
"engines": {
"node": ">=4.0.0",
"npm": ">=3.0.0"
},
"scripts": {
"lint": "aegir-lint",
Expand Down Expand Up @@ -74,6 +77,7 @@
"fs-pull-blob-store": "^0.3.0",
"glob": "^7.1.1",
"hapi": "^15.2.0",
"hapi-set-header": "^1.0.2",
"idb-pull-blob-store": "^0.5.1",
"ipfs-api": "^11.1.0",
"ipfs-bitswap": "^0.8.1",
Expand Down Expand Up @@ -110,6 +114,7 @@
"pull-stream-to-stream": "^1.3.3",
"pull-zip": "^2.0.1",
"read-pkg-up": "^2.0.0",
"readable-stream": "^1.1.14",
"stream-to-pull-stream": "^1.7.2",
"tar-stream": "^1.5.2",
"temp": "^0.8.3",
Expand Down
6 changes: 6 additions & 0 deletions src/http-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const path = require('path')
const IPFSRepo = require('ipfs-repo')
const multiaddr = require('multiaddr')
const Store = require('fs-pull-blob-store')
const setHeader = require('hapi-set-header')

const log = debug('api')
log.error = debug('api:error')
Expand Down Expand Up @@ -52,6 +53,7 @@ exports = module.exports = function HttpApi (repo) {
}
}
})

this.server.app.ipfs = this.ipfs
const api = config.Addresses.API.split('/')
const gateway = config.Addresses.Gateway.split('/')
Expand All @@ -75,6 +77,10 @@ exports = module.exports = function HttpApi (repo) {
// load routes
require('./routes')(this.server)

// Set default headers
setHeader(this.server, 'Access-Control-Allow-Headers', 'X-Stream-Output, X-Chunked-Output, X-Content-Length')
setHeader(this.server, 'Access-Control-Expose-Headers', 'X-Stream-Output, X-Chunked-Output, X-Content-Length')

this.ipfs.goOnline(() => {
this.server.start((err) => {
if (err) {
Expand Down

0 comments on commit 6a21cd0

Please sign in to comment.