Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow different host through CLI flag #1475

Merged
merged 7 commits into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ describe('get reload script', () => {
test('when server started, returns url with correct port', () => {
const port = 1234;
liveReloadServer.start(port);
const expectedUrl = `http://localhost:${port}/livereload.js`;
const expectedUrl =
process.platform === 'win32'
palmer-cl marked this conversation as resolved.
Show resolved Hide resolved
? `http://localhost:${port}/livereload.js`
: `http://0.0.0.0:${port}/livereload.js`;
expect(liveReloadServer.getReloadScriptUrl()).toBe(expectedUrl);
});
});
4 changes: 3 additions & 1 deletion packages/docusaurus-1.x/lib/server/liveReloadServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ function start(port) {

const getReloadScriptUrl = () => {
const port = process.env.LIVERELOAD_PORT;
return `http://localhost:${port}/livereload.js`;
const server = process.platform === 'win32' ? 'localhost' : '0.0.0.0';
palmer-cl marked this conversation as resolved.
Show resolved Hide resolved

return `http://${server}:${port}/livereload.js`;
};

module.exports = {
Expand Down