Laravel Sanctum SPA with React js unexpected logout error 401 (Unauthorized) - reactjs

My application works perfectly (Login and all other apis) using laravel Sanctum SPA authentication with react js. But sometimes the system is logout unexpectedly, api response shows error 401 Unauthorized. Message: Unauthenticated.
Searched the web for this issue but found nothing useful.

Related

Vercel React app makes rest calls to http endpoints

Hi I have a react application that runs on vercel so in https and the backend is on a vps, the backend has no https and when I run the rest calls from frontend to backend I have the following error how do I solve it?
Error:
xhr.js:220 Mixed Content: The page at 'https://vmgroupfrontend.vercel.app/#/login' was loaded over HTTPS, but requested an insecure
XMLHttpRequest endpoint 'http://myendpoint.org:3001/user/login'.
This request has been blocked; the content must be served over HTTPS.

AWS Amplify ReactJS app trouble reloading page

I'm currently working on a full-stack project mainly using ReactJS and AWS Amplify. I've successfully deployed the website but the URL routings only seem to work if I redirect from the home page. I can only load the home page www.website.com but I try to manually type in www.website.com/login/, it gives me this message
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>B2173BDEE0658858</RequestId>
<HostId>
TRevHdaqGZYTUxU9W1wXc3CQccfLeznHlYLcbuF+Wr511FVmOPFBp4tpyccJ2t5QMVpvYygNNb4=
</HostId>
</Error>
I've looked up solutions from other StackOverflow pages but it didn't seem to solve the issue.
I have tried adding a redirect rule in the AWS console provided (Getting 403 ACCESS DENIED error when deploying React Web app on AWS Amplify) but the issue persists. Is there a way to fix this?
You have to set up a 404 (page not found) redirect on the AWS Amplify to point on the index.html.
React App is SPA (Single Page App) it has its own routing, and on the AWS side, all other routes except base path will return 404, because they don't exist on the server-side.
Once you setup 404 to points on your React application again, React router will handle the routing.
Check: docs.aws.amazon.com/amplify/latest/userguide/redirects.html and pay attention to 404 redirections.

HTTPS Error while refreshing the page in ReactJS

enter image description hereWe have developed our frontend in ReactJs. The website is showing HTTPS error after refreshing any page of the website.
What could be the possible error and how to resolve it?

Ionic 3 HTTP Status Code 401 changed to 0

I am using ionic 3 with spring boot at the back end. Spring Boot API are secured with Spring Security JWT Token.
While tying to execute any API, if the token has not expired the API is working properly.
Once token is expired its expected that API should return 401 status code, but in the ionic its always returning status code a 0(Zero).
However if we check the Network in the chrome browser, its showing correct response code as 401, but the ionic code its coming as 0(Zero)
Ionic Code Sample
var url = this.masterConfig.ADMIN_SERVER_URL +'/home';
this.http.get(url,getOptions).subscribe(data => {
console.log('Data :::'+data);
},error =>{
console.log('Error :::'+error);
console.log('Error :::'+error.status);
console.log('Error :::'+error.error);
});
Network Logs
Console Log
If you happen to be using the Auth0 Angular2-jwt component, then this behavior has been reported as an issue. That's the only time I've personally run into this behavior with Ionic 3 and HTTP response issues.

Social Signin Invalid CSRF Token

I have an issue with jhipster application sign in functionality. When I try to login with Google or Facebook from the Login form I get :
Sorry, an error has occurred.
Status: Forbidden (Forbidden)
Message: Invalid CSRF Token '0f400828-c705-4cb2-9de0-b24c005152bf' was found on the request parameter '_csrf' or header 'X-XSRF-TOKEN'.
The strange thing is that it works from Register form.
I am using jHipster version v4.3.0 and angularjs.

Resources