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

Commit

Permalink
fix: add cors support for preload-mock-server and update aegir (#1839)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias authored and alanshaw committed Jan 23, 2019
1 parent c8cb245 commit 2d45c9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
"homepage": "https://github.com/ipfs/js-ipfs#readme",
"devDependencies": {
"aegir": "^17.1.1",
"aegir": "^18.0.3",
"chai": "^4.2.0",
"delay": "^4.1.0",
"detect-node": "^2.0.4",
Expand Down
9 changes: 9 additions & 0 deletions test/utils/mock-preload-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ module.exports.createNode = () => {
let cids = []

const server = http.createServer((req, res) => {
res.setHeader('Access-Control-Allow-Origin', '*')
res.setHeader('Access-Control-Request-Method', '*')
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET, DELETE')
res.setHeader('Access-Control-Allow-Headers', '*')
if (req.method === 'OPTIONS') {
res.writeHead(200)
res.end()
return
}
if (req.url.startsWith('/api/v0/refs')) {
const arg = new URL(`https://ipfs.io${req.url}`).searchParams.get('arg')
cids = cids.concat(arg)
Expand Down

0 comments on commit 2d45c9d

Please sign in to comment.