How to use window.location.href in Electron? - reactjs

I have a react app which I've converted to Electron app also.
In the app after I logout I'm redirecting the user back to login screen using
window.location.href="/login"
it is working perfectly in React build. But in Electron build it is not redirecting to the login route rather the app crashes. In the network tab there is an API call made to C:///login in Windows. So I am confused on how to use the same in React and Electron without breaking UI.

Related

After a refresh, the React App in Netlify crashed

After deploying my React app in Netlify, when I refresh my base url's page, it works, but when I refresh other routes, the app crashes.
I want the browser to load the specific route's contents after refreshing the page.

AWS Amplify not opening file

I'm trying to open a .html file "resume.html" on my website. This is my "public" folder.
I'm using React, and I'm trying to open "resume.html" in a new tab on button click with this code:
<Resume className="resume" onClick={() => window.open("/resume.html", "_blank")}>View Resume</Resume>
Everything works fine during development. on my localhost: 3000, the resume opens in a new tab just fine. But when I host the site on AWS Amplify, the button click loads "index.html".
I have no idea why the AWS amplify server would be loading a different file than my localhost server.
If you use ReactJS then everything will go through a build step to create the deployment assets that make up the Single Page Application. The result of this build step is what will be deployed to be hosted on AWS.
For navigation in ReactJS it is better to use a routing library like React Router. You can create a new React Component for the resume content and navigate to it using a Router Link. This will work better for the Single Page Application to understand rather than opening a HMTL page with window.open.

Deploying React Router application to Subfolder on Server

The Problem:
We have our website https://website.com and we are trying to deploy a react router application to https://website.com/react-app. Routing works fine if the user first navigates to https://website.com/react-app and then navigates around the app from there. However, if someone navigates to https://website.com/react-app/home directly (or via bookmark) they get a 404 even though /home is one of our routes.
What We tried:
In our package.json we have the "homepage": "/react-app/" set. Using BrowserRouter we set the basename prop to /react-app and the app works when deployed except for 404 when navigating directly to a nested route. We have heard that HashRouter can be useful in this situation, however, when we use HashRouter we are getting https://website.com/react-app#/ instead of https://website.com/react-app/#/.
How can we configure this to allow users to navigate directly to nested routes in our React Router application deployed to a the /react-app Subfolder on our server?
React: 17.0.2, React-Router-Dom: 5.2.0
I think the problem must be not connected with React. Your React app is configured right. Check the configuration of your web server. Your webserver must return index.html with React application when the user navigates to any page.

Problem with routing on react app on heroku

I have problem with my app on heroku
https://quiet-meadow-74770.herokuapp.com/
When I click register and refresh page, I have a error.
What should I do?

Electron React : Unable to view console log from react

I have Electron app which access react app running on dev server. I use loadURL("http://localhost:3000/") to access the reactapp within electron. The react app having console logs however not able to view the logs anywhere. how do I view these log messages
NB: I am new to JS /react/Electron and come from enterprise java background
For the render process you can start here.
https://electronjs.org/docs/tutorial/application-debugging
for the main process you can see here.
https://electronjs.org/docs/tutorial/debugging-main-process
if you are using vscode you can use this handy guide.
https://electronjs.org/docs/tutorial/debugging-main-process-vscode

Resources