diff --git a/src/core/components/bootstrap.js b/src/core/components/bootstrap.js index bfa5d14bdb..af2bd95818 100644 --- a/src/core/components/bootstrap.js +++ b/src/core/components/bootstrap.js @@ -1,6 +1,10 @@ 'use strict' -const defaultNodes = require('../../init-files/default-config.json').Bootstrap +const isNode = require('detect-node') + +const defaultNodes = isNode + ? require('../../init-files/default-config-node.json').Bootstrap + : require('../../init-files/default-config-browser.json').Bootstrap module.exports = function bootstrap (self) { return { diff --git a/src/core/components/init.js b/src/core/components/init.js index 0350563a0e..59d517544a 100644 --- a/src/core/components/init.js +++ b/src/core/components/init.js @@ -3,6 +3,7 @@ const peerId = require('peer-id') const waterfall = require('async/waterfall') const parallel = require('async/parallel') +const isNode = require('detect-node') const addDefaultAssets = require('./init-assets') @@ -20,13 +21,9 @@ module.exports = function init (self) { opts.bits = Number(opts.bits) || 2048 opts.log = opts.log || function () {} - let config - // Pre-set config values. - try { - config = require('../../init-files/default-config.json') - } catch (err) { - return callback(err) - } + const config = isNode + ? require('../../init-files/default-config-node.json') + : require('../../init-files/default-config-browser.json') waterfall([ // Verify repo does not yet exist. @@ -62,9 +59,7 @@ module.exports = function init (self) { ] if (typeof addDefaultAssets === 'function') { - tasks.push( - (cb) => addDefaultAssets(self, opts.log, cb) - ) + tasks.push((cb) => addDefaultAssets(self, opts.log, cb)) } parallel(tasks, (err) => { diff --git a/src/init-files/default-config-browser.json b/src/init-files/default-config-browser.json new file mode 100644 index 0000000000..93fbbbdd58 --- /dev/null +++ b/src/init-files/default-config-browser.json @@ -0,0 +1,9 @@ +{ + "Addresses": { + "Swarm": [], + "API": "/ip4/127.0.0.1/tcp/5002", + "Gateway": "/ip4/127.0.0.1/tcp/9090" + }, + "Discovery": {}, + "Bootstrap": [] +} diff --git a/src/init-files/default-config.json b/src/init-files/default-config-node.json similarity index 83% rename from src/init-files/default-config.json rename to src/init-files/default-config-node.json index 33046e3871..91736bf291 100644 --- a/src/init-files/default-config.json +++ b/src/init-files/default-config-node.json @@ -1,7 +1,8 @@ { "Addresses": { "Swarm": [ - "/ip4/0.0.0.0/tcp/4002" + "/ip4/0.0.0.0/tcp/4002", + "/ip4/127.0.0.1/tcp/4003/ws" ], "API": "/ip4/127.0.0.1/tcp/5002", "Gateway": "/ip4/127.0.0.1/tcp/9090" @@ -12,17 +13,6 @@ "Interval": 10 } }, - "Mounts": { - "IPFS": "/ipfs", - "IPNS": "/ipns" - }, - "Ipns": { - "ResolveCacheSize": 128 - }, - "Gateway": { - "RootRedirect": "", - "Writable": false - }, "Bootstrap": [ "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", "/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", diff --git a/test/http-api/spec/test-bootstrap.js b/test/http-api/spec/test-bootstrap.js index 6c25584393..0e830f04ea 100644 --- a/test/http-api/spec/test-bootstrap.js +++ b/test/http-api/spec/test-bootstrap.js @@ -3,7 +3,7 @@ const expect = require('chai').expect const qs = require('qs') -const defaultList = require('../../../src/init-files/default-config.json').Bootstrap +const defaultList = require('../../../src/init-files/default-config-node.json').Bootstrap module.exports = (http) => { describe('/bootstrap', () => {