i don't want use server side rendering because absolute pain working , i've gotten working without it.
however if make new url /test
, visit localhost:3000/test cannot /test
this how index page being served up
app.get("/", function(req, res) { res.sendfile(__dirname + '/client/index.html') })
routes file
const routes = ( <div> <route path="/" component={ appcontainer }> <indexroute component={ registrationcontainer }/> <route path="test" component={ stripecontainer }/> </route> </div> ) export default routes
i'm working on right , think you'll need declare /test
path before react route.
how i'm going implement in app declare routes in express user login , have catchall @ end send else react.
something
app.get('/login', function(...)); app.get('/logout', function(...)); app.get('*', <to-react>);
i'm not sure if right way go dealing issue should work.
let me know how works or if foresee issues using this.
update: can confirm working me now. here abbreviated versions of express routes file , base react file.
routes
// redirects requests root of domain react (a polling app) app.get('/', function(req, res) { res.redirect('/polls'); }); // authentication routes app.get('/login' function(....)); app.get('/logout' function(....)); app.get('/login/callback' function(....)); app.get('/login/authorise' function(....)); // react catch route app.get('*', function(....{sendfile....});
base react file
import react 'react'; import reactdom 'react-dom'; import {router, route, redirect, browserhistory} 'react-router'; const polllistscreen = require('./polllistscreen.js'); const polladd = require('./polladd.js'); reactdom.render( ( <router history={browserhistory}> <route path='/polls' component={polllistscreen} /> <route path='/polls/new' component={polladd} /> </router> ), document.getelementbyid('app') );