react-router-tutorial icon indicating copy to clipboard operation
react-router-tutorial copied to clipboard

Issues at step 11 /public folder location

Open yarnball opened this issue 8 years ago • 6 comments

Hi,

After tutorial 11 of your tutorial, the project will only work locally. When I uploaded my project (upto step 11) to my webserver it gave a 403 error.

However, all tests before tutorial 11 worked fine.

When index.html is located on the root folder- it works fine.

I believe this is probably related to moving the index.html to /public.

Can you advise?

yarnball avatar Sep 05 '16 14:09 yarnball

No the issue is when you keep <script src="/bundle.js"></script>

You should switch it to <script src="/public/bundle.js"></script>

jakeecolution avatar Sep 26 '16 02:09 jakeecolution

#242 Check out my PR.

jakeecolution avatar Sep 26 '16 02:09 jakeecolution

@bryanj4 Thanks for the advice, man, worked like a charm. Note, though, that moving along with the tutorial, we: a) Create the public directory b) Move our index.html and index.css files there, as @yarnball has stated.

Which means it seems to be better to do the following:

  1. Add the <script src="/public/bundle.js"></script> after we make a first change to the webpack.config.js
  2. Then remove the /public part right in the end of the tutorial.

At least this is how I made it work. Hope anybody else will find this useful.

mawansui avatar Sep 27 '16 13:09 mawansui

I think I fixed it by changing ~line 12 of server.js to:

res.sendFile(path.join(__dirname, './public/index.html'))

smilingkylan avatar Oct 27 '16 05:10 smilingkylan

The output path of webpack.config.js before server.js is modified should be set to root folder, otherwise bundle.js will fail to load (in README.md)

bondansebastian avatar Dec 05 '16 07:12 bondansebastian

Also bug #218, fix #310

merriam avatar Mar 21 '17 12:03 merriam