Skip to content
This repository has been archived by the owner on Jul 19, 2019. It is now read-only.

lesson 14 broken #159

Closed
dawsbot opened this issue Apr 19, 2016 · 13 comments
Closed

lesson 14 broken #159

dawsbot opened this issue Apr 19, 2016 · 13 comments

Comments

@dawsbot
Copy link

dawsbot commented Apr 19, 2016

Upon download, I execute npm install within /react-router-tutorial/lessons/14-whats-next. After this is installed, I execute npm start and the build begins.

Webpack does it's work and tells me to visit http://localhost:8080 to see the app, but I am greeted with the less-than-friends Cannot GET / response in my browser. There are no build errors, and webpack waits in it's post-build waiting state.

Am I doing something wrong?



sist output:

OS

Darwin
x64

shell

uname: Darwin
echo $SHELL: /bin/zsh
echo $TERM: xterm-256color
echo $TERM_PROGRAM: iTerm.app

node

npm -v: 3.6.0
node --version: v5.7.1

Time created: Mon Apr 18 2016 18:16:23 GMT-0600 (MDT)

@shenbin04
Copy link

shell

uname: Linux
echo $SHELL: /bin/zsh
echo $TERM: screen-256color
echo $TERM_PROGRAM:

node

npm -v: 3.7.3
node --version: v5.9.1

Time created: Tue Apr 19 2016 13:58:35 GMT-0400 (EDT)

@shenbin04
Copy link

Actually I have some thoughts.
It does not work because webpack-dev-server is only serving the bundled js
but in the final code base, the page is rendered by server, and the static html
is not there anymore, so spin up another web server can solve the issue

@hutber
Copy link

hutber commented Apr 20, 2016

+1

And how do we fix it? when you say web server you mean: NODE_ENV=server npm build?

@xiaopow
Copy link

xiaopow commented Apr 28, 2016

Guys, npm start doesn't work because the static index.html is missing in /public for lesson 14. You just need to add it back it for it to work.

@dawsbot
Copy link
Author

dawsbot commented Apr 28, 2016

If adding it back is required it should be in the source, right @xiaopow? Care to make a PR with your change?

@timdorr
Copy link
Member

timdorr commented Apr 28, 2016

No, that is not correct. The server has a built-in copy of the index.html file.

Is express.static eating the index request?

@xiaopow
Copy link

xiaopow commented Apr 28, 2016

Sorry, but it is true. Just need to add index.html back to /public. We are talking about npm start not NODE_ENV=production npm start

@timdorr
Copy link
Member

timdorr commented Apr 28, 2016

No, it's not. The server is capable of rendering itself, so an index.html file is entirely redundant. Remove the express.static line and it will work. (Albeit, without the CSS working)

The issue was that we weren't configuring that middleware to not do directory indexing. I've fixed that now.

@timdorr timdorr closed this as completed Apr 28, 2016
@xiaopow
Copy link

xiaopow commented Apr 28, 2016

Hey, I have swapped it with your fix app.use(express.static(path.join(__dirname, 'public'), {index: false})) but am still getting Cannot GET / for npm start.

NODE_ENV=production npm start works fine as usual.

@sameenzm
Copy link

hey, I have removed the express.static line, but it dosen't work too. Are you sure you have fixed that now ? @timdorr

@dawsbot
Copy link
Author

dawsbot commented Aug 23, 2016

@sameenzm, what version are you running? Ensure you're on the newest and then if your problem persists, a "sist" output may help. See my first comment for the "sist" link.

@timdorr
Copy link
Member

timdorr commented Aug 23, 2016

@sameenzm You should leave that line in place. If you notice, we added the {index: false} option. That means it will serve up any file, except for any index file (e.g., index.html when you request /). This is so that the server can do rendering on those pages and send over pre-built HTML to the browser. If you serve up the index file, the browser will have to do the rendering and start from scratch.

@yura-master-web
Copy link

add index.html iv folder 'public' and npm start run
its work

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants