Skip to content

Commit

Permalink
Fixed standalone bug that prevented backend from being served over lo…
Browse files Browse the repository at this point in the history
…calhost:8097
  • Loading branch information
Brian Vaughn committed Aug 18, 2019
1 parent 95ffd3c commit 95ca079
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/react-devtools-core/src/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Bridge from 'src/bridge';
import Store from 'src/devtools/store';
import { getSavedComponentFilters, getAppendComponentStack } from 'src/utils';
import { Server } from 'ws';
import { join } from 'path';
import { existsSync, readFileSync } from 'fs';
import { installHook } from 'src/hook';
import DevTools from 'src/devtools/views/DevTools';
Expand Down Expand Up @@ -258,9 +259,10 @@ function startServer(port?: number = 8097) {
httpServer.on('request', (request, response) => {
// NPM installs should read from node_modules,
// But local dev mode needs to use a relative path.
const basePath = existsSync('./node_modules/react-devtools-core')
? 'node_modules/react-devtools-core'
: '../react-devtools-core';
let basePath = join(__dirname, 'node_modules/react-devtools-core');
if (!existsSync(basePath)) {
basePath = '../react-devtools-core';
}

// Serve a file that immediately sets up the connection.
const backendFile = readFileSync(`${basePath}/dist/backend.js`);
Expand Down

0 comments on commit 95ca079

Please sign in to comment.