React engine is causing "Cannot find module" error

831 views Asked by At

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.

1

There are 1 answers

0
ThomasReggi On BEST ANSWER

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