reactjs - Fetch React router paths from server -


i have website around 10,000 urls , these urls cleaned using server side url rewrite. means, if have url http://example.com/best-cakes-in-sydney maps http://example.com/cakes?city=sydney. want use http://example.com/best-cakes-in-sydney url in react app.

but problem that, impossible include parameter in these urls, not follow specific pattern. due forced write down these urls in react router config. writing down 10,000 paths in react router file not seems idea.

please me of following:

  1. if possible generate react router config file work. in on rendering of file ajax request go on server , pull paths hence things not hardcoded.
  2. is there other way tackle problem?

i think can send server information component want render on specific url.

if request /best-cakes-in-sydney server return json {component: "cakes", city: "sydney", content: "...", ...}

then pick right component:

switch(response.component){   case 'cakes': ...}     <cakes /> } 

so don't have use router, or 1 global route this.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -