scalable-react / scalable-react-boilerplate

:star: Scalable feature-first React micro-framework made for Udacity Alumni collaborative projects
https://scalable-react-boilerplate.herokuapp.com/
MIT License
259 stars 60 forks source link

Serverside rendering doesn't function when requesting index.html #60

Closed daan-nguyen closed 7 years ago

daan-nguyen commented 7 years ago

It appears when making a request to the root entry (localhost:1337/ or localhost:1337/index.html) the server side rendering doesn't initiate.

I think it's this part here in the app.js. The static file serving is finding the index.html first, so it skips the code that will provide server side rendering. Hitting the /about route directly seems to work correctly as the file doesn't resolve on static file serving.

app.use(express.static(__dirname + '/public'));

app.use((req, res) => { ...

You can verify this by just deleting or renaming the index.html file in server/public.

PS. Great boilerplate project! We are evaluating a few atm and this one is definitely our favourite, esp like the generators. The recent sans-apollo branch has been really helpful since we aren't in a position to make use of it.

RyanCCollins commented 7 years ago

@daan-nguyen awesome! I am really glad you're enjoying it. I'd love to hear about anything you end up building with it 😄 .

Nice catch on the server-side rendering!!! That is great. Hey, if you're able to, can you submit a PR to fix this? It'd be really helpful. If not, no worries. It might take me a bit to get to it as I am just starting a new job.

Thanks again and please let me know if you have any questions or more issues.

daan-nguyen commented 7 years ago

@RyanCCollins PR created! Just removed the index.html from being generated as part of production build since SSR is available. The production template would then be the Html.js file in server/utils.

Future improvement may be to generate the Html.js file from a template file in the template folder, letting all templates live in one place logically.

RyanCCollins commented 7 years ago

Nice job fixing this! #63 has been merged and closed.