1

I'm using react-engine to supply the server with access to react components. With react-engine you can feed an express react by routing a url and using res.render. To do this you need to provide a path the docs specify req.url.

app.use("/", function(req, res){
    return res.render(req.url, data);
})

Now when the url is /index that will be passed into react-router and the react route will be compiled into a string as returned at that endpoint.

The issue I'm having is when the url has a period.

Whenever there is a period in the get query (/index.html) or the route path itself (/index?example=foo.bar) I get an error stating the following.

Cannot find module 'html'

or

Cannot find module 'bar'

respectively.

Do I have to escape periods to the url?

res.render(req.url.replace(/\./g, ""), data)

How can I get rid of the Cannot find module 'extension' message?

I also put a specific issue here in react-engine on github.

laser
  • 1,388
  • 13
  • 14
ThomasReggi
  • 55,053
  • 85
  • 237
  • 424
  • I'm digging into this and I think it might have something two do with teh express view engine [here](https://github.com/paypal/react-engine/blob/master/lib/expressView.js#L23). The error occurs when any route contains a period: http://stackoverflow.com/questions/16111386/node-js-cannot-find-module-html – ThomasReggi Jul 10 '15 at 17:12
  • I think its happening because `express/lib/view` thinks that the file being passed is a normal view template like `index.jade` and what it does is parses the extension to find what templating library it is using https://github.com/strongloop/express/blob/master/lib/view.js#L76-L79 – ThomasReggi Jul 10 '15 at 17:16

1 Answers1

0

I put up a PR on react-engine a while back.

https://github.com/paypal/react-engine/pull/58

There's also a long-running issue open here:

https://github.com/paypal/react-engine/issues/52

ThomasReggi
  • 55,053
  • 85
  • 237
  • 424