react-router-tutorial
react-router-tutorial copied to clipboard
Issues at step 11 /public folder location
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?
No the issue is when you keep <script src="/bundle.js"></script>
You should switch it to <script src="/public/bundle.js"></script>
#242 Check out my PR.
@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:
- Add the
<script src="/public/bundle.js"></script>
after we make a first change to the webpack.config.js - 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.
I think I fixed it by changing ~line 12 of server.js to:
res.sendFile(path.join(__dirname, './public/index.html'))
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
)
Also bug #218, fix #310