question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

If app starts in certain paths redirect to root

See original GitHub issue

This issue requires knowledge of react and react-router.

Thank you for your help ❤️

What is this project?

DAV (Decentralized Autonomous Vehicles) is a new foundation working to build an open-source infrastructure for autonomous vehicles (cars, drones, trucks, robots, and all the service providers around them) to communicate and transact with each other over blockchain.

Missions

The DAV project you are looking at is Missions. Missions is the client facing side of the marketplace connecting DAV users looking to ship packages, with autonomous vehicles such as drones.

How you can help

Missions is a web app built using React and React Router. When a user clicks links in the app the url gets updated. If the user refreshes the page when the url is pointing at certain routes (or enters those urls directly) we do not have all the information needed to display those pages, and would want to redirect the user to the root route instead.

Add code to a central location that will check the current url when the app loads, and if it is /searching push the / url to the history (which will cause it to navigate there). In the future we will have more conditions here which will cause it to navigate. My initial instinct is to do this in the App component (as it has access to the router, and it is the first component to load (after its wrapper: Main)).

To run the project locally, you will need to clone it, run npm run, and then visit http://localhost:3333/. Detailed instructions are below:

Contributing to Missions

  • Fork the repository from the Missions GitHub page.
  • Clone a copy to your local machine with $ git clone git@github.com:YOUR-GITHUB-USER-NAME/missions.git
  • Make sure you have node.js and npm installed on your machine. You can use this guide for help.
  • Install all of the project’s dependencies with npm. $ cd missions; npm install
  • Run gulp watch:js to start a local server and watch your local code for changes. The server will restart automatically every time you change the code.
  • Code! code! code!
  • Before committing your code, run gulp one last time and make sure no errors (including linting errors) are thrown.
  • Once you’ve made sure all your changes work correctly, and committed all your changes, push your local changes back to github with $ git push -u origin master
  • Visit your fork on GitHub.com (https://github.com/YOUR-USER-NAME/missions) and create a pull request for your changes.
  • Make sure your pull request describes exactly what you changed and references this issue (include the issue number in the title like this: #26)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Rob-Rychscommented, Oct 9, 2017

Hey I owe an update on this one. Working on it has essentially just been going through learning react and react-router docs, making notes and going through working with some examples. At first i just wrote a couple of redirects which was pretty hacky and not a sustainable solution. I think this issue could actually be solved by using browserhistory with a Switch and passing the previousURL to the next path using nested routes… i’m going to try experimenting with it this week and report back

1reaction
ZackTaylorcommented, Oct 14, 2017

Hey all I’ll give this a shot and check in with an update soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to redirect all url paths to the root handler in App ...
Angular takes care for routing. As you probably noticed this is Server-Side Rendering (SSR), but redirection of all routes to index.html (or ...
Read more >
How to Set React Router Default Route Redirect to /home
The route is a statement that holds the specific path of the app along with the component's name and renders it once it...
Read more >
How to implement redirects in Next.js - LogRocket Blog
Redirects enable users to transfer an executed URL to a new URL to reroute an incoming request from one path to another.
Read more >
Configuring Routes and Domains | Cloud Foundry Docs
Routes with the same domain and hostname but different paths can only be created in the same space. Private domains do not have...
Read more >
Configure Azure Static Web Apps - Microsoft Learn
Values must be relative to the root of the app. redirect, No, n/a, Defines the file or path redirect destination for a request....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found