facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
56.98k stars 8.58k forks source link

Need to add "index.html" to make dev server work #603

Closed sebelga closed 6 years ago

sebelga commented 6 years ago

Hi,

In my dev environement I need to add "/index.html" to

Otherwise I get a server timeout error (the page does not defaults to "index.html").

Any idea why that might be happening? Cheers.

JoelMarcey commented 6 years ago

@sebelga Hi. Can you provide more details?

sebelga commented 6 years ago

Hi @JoelMarcey

I have version 1.0.1 of "docusaurus-init" and version "1.0.14" of "docusaurus" in my project node_modules. I am on Windows 7 64-bit

I can't provide a link as the repo is not public but here is my siteConfig.js (I only made update of some props and commented stuff)

/**
 * Copyright (c) 2017-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

// See https://docusaurus.io/docs/site-config.html for all the possible
// site configuration options.

/* List of projects/orgs using your project for the users page */
const users = [
  // {
  //   caption: 'User1',
  //   image: '/test-site/img/docusaurus.svg',
  //   infoLink: 'https://www.facebook.com',
  //   pinned: true,
  // },
];

const siteConfig = {
  title: 'eUI Documentation' /* title for your website */,
  tagline: 'All you ever wanted to know about eUI',
  url: 'https://eui.ec.eu' /* your website url */,
  baseUrl: '/' /* base url for your project */,
  // For github.io type URLs, you would set the url and baseUrl like:
  //   url: 'https://facebook.github.io',
  //   baseUrl: '/test-site/',

  // Used for publishing and more
  projectName: 'eUI',
  organizationName: 'European Commission',
  // For top-level user or org sites, the organization is still the same.
  // e.g., for the https://JoelMarcey.github.io site, it would be set like...
  //   organizationName: 'JoelMarcey'

  // For no header links in the top nav bar -> headerLinks: [],
  headerLinks: [
    {doc: 'basics-getting-started', label: 'Docs'},
    // {doc: 'doc4', label: 'API'},
    {page: 'help', label: 'Help'},
    // {blog: true, label: 'Blog'},
  ],

  // If you have users set above, you add it here:
  // users,

  /* path to images for header/footer */
  headerIcon: 'img/ec-logo.svg',
  footerIcon: 'img/eui-logo.svg',
  favicon: 'img/favicon.ico',

  /* colors for website */
  colors: {
    primaryColor: '#4583d7',
    secondaryColor: '#1b4986',
  },

  /* custom fonts for website */
  /*fonts: {
    myFont: [
      "Times New Roman",
      "Serif"
    ],
    myOtherFont: [
      "-apple-system",
      "system-ui"
    ]
  },*/

  // This copyright info is used in /core/Footer.js and blog rss/atom feeds.
  copyright:
    'Copyright © ' +
    new Date().getFullYear() +
    ' European Commission',

  highlight: {
    // Highlight.js theme to use for syntax highlighting in code blocks
    theme: 'default',
  },

  // Add custom scripts here that would be placed in <script> tags
  scripts: ['https://buttons.github.io/buttons.js'],

  /* On page navigation for the current documentation page */
  onPageNav: 'separate',

  /* Open Graph and Twitter card images */
  ogImage: 'img/docusaurus.png',
  twitterImage: 'img/docusaurus.png',

  // You may provide arbitrary config keys to be used as needed by your
  // template. For example, if you need your repo's URL...
  //   repoUrl: 'https://github.com/facebook/test-site',
};

module.exports = siteConfig;

When I build the website, I do have the "index.html" generated and it works fine.

Thank for your help!

yansern commented 6 years ago

I can confirm this is happening to me too. Like @sebelga I am also using Windows 7 64-bit.

Without copying the index.html files from the build folder, accessing http://localhost:3000 will stall for a long time until a timeout occurs.

After performing a fresh installation of docusaurus, I have to:

cd website
yarn build
cp build\test-site\index.html static\index.html
mkdir static\blog
cp build\test-site\blog\index.html static\blog\index.html
yarn start

Then only I can open http://localhost:3000 properly.

UPDATE: I believe this affects Windows platform (as the same is happening on Windows Server 2012). I have tried both NodeJS v8 and NodeJS v10.

endiliey commented 6 years ago

Just adding some data here. With fresh install, I use Windows 10 64-bit through its WSL (Windows Subsystem for Linux) and it works fine. Tried using normal command prompt and it works fine as well. I couldn't reproduce the error.

JoelMarcey commented 6 years ago

@yansern @sebelga @endiliey Not sure you have the means to test this, but if you perform the same steps on a Mac or Linux machine, I assume you don't get the issue?

I just want to pinpoint that this is a Windows-specific problem.

endiliey commented 6 years ago

I don't have Mac but just tested it on Ubuntu 16.04.02 LTS with Node v8.10.0 and it worked fine. Latest Docosaurus is being used

JoelMarcey commented 6 years ago

So this looks like a Windows support issue.

There is a PR - https://github.com/facebook/Docusaurus/pull/677 - it may not be directly related, but I wonder if it could help.

endiliey commented 6 years ago

It would be very helpful if there is at least a repository in which we can reproduce this bug. If this happens to all windows, then it's obvious that this need to be fixed.

Before all of that, @yansern @sebelga can you try forking Docosaurus and try running it in your local server? Just to pinpoint it's not from old version bug

yarn install
cd website
yarn start

It assume that this only happens on dev server, which is related to Express server routing.

yansern commented 6 years ago

Hi @JoelMarcey & @endiliey, I have figured out the issue and it is proxy related.

I'm running behind corporate proxy and I have HTTP_PROXY & HTTPS_PROXY environment variable set. (I wouldn't use Windows 7 unless I had to, I'm a Mac user by heart lol.) I believe @sebelga might be also running behind corporate proxy.

I noticed that under lib/server/server.js, requests ending with / are handled by using the request library to connect explicitly to http://localhost:3000/index.html and send the content back to Express.

What happens is that this request library trying to retrieve http://localhost:3000/index.html through a proxy and therefore unable to resolve to any site and timed out after awhile.

Looking up the docs for request, one can control addresses that shouldn't go through a proxy using the NO_PROXY environment: https://www.npmjs.com/package/request#controlling-proxy-behaviour-using-environment-variables

The solution is just to set localhost to the NO_PROXY environment variable:

SET NO_PROXY = localhost
yarn start

Other tips:

  1. Use comma separator for multiple hostnames, e.g. SET NO_PROXY = localhost,127.0.0.1.
  2. npm also respects NO_PROXY env variable.
endiliey commented 6 years ago

@yansern Thank you for this knowledge & information. Let's see if this work for @sebelga due to him having proxy env set and we might need to consider adding this to documentation. Awesome, i learned something new today.

sebelga commented 6 years ago

Sorry I haven't replied to previous messages.

@yansern effectively I am behind a corporate proxy with HTTP_PROXY env vars set. :smile:

And your fix worked indeed! But it needs to be set without any spaces

SET NO_PROXY=localhost

Thanks!

endiliey commented 6 years ago

That should be it then. I guess we can close this issue. Horaay 😀. Another thing is @yansern or @sebelga do you want to submit a doc PR for this ? I think that will be helpful. Cc @joelmarcey

sebelga commented 6 years ago

Yeah sure I can do it. Should I include it in the "Installation" section? https://docusaurus.io/docs/en/installation.html

JoelMarcey commented 6 years ago

Glad this is resolved. And thanks for #688 😄