integration between reactjs and spring mvc - reactjs

I am trying to upgrade an existing application which has Spring MVC with JSP frontend to ReactJs. I am not sure how to integrate Reactjs frontend with Spring mvc backend. Right now i compile the react app and put it inside the backend app
Then spring mvc maps to the react app. The integration between is with spring rest.
What is the best practice? I think that it will be much easier to have 2 separate application React frontend and spring backend. There are 2 big issues with this solution.
How should the react app authenticate to backend? Backend use Spring security. I know that i can use rest tokens, but i am not sure how.
If i use react-router then i need to map all react-routes to spring mvc.
I dont find any good example online. Any help would be appropriated.

Related

React + Laravel, should I do it in 1 or 2 seperate repositories?

After learning Laravel basics and React.js basics I want to build an app that use Laravel for backend and React.js for frontend. Would it be better to include the React.js in Laravel app with artisan ui react or do it in 2 seperate repositories, 1 for Laravel to build APIs and include it in an addon domain e.g www.api.mywebsite.com which would act as a backend website and redirect to the React.js app if accessed by public and 1 for React.js app that would be used for public, on the main domain e.g www.mywebsite.com which would just fetch data over www.api.mywebsite.com. So which way is better as I'm developing both frontend and backend, and I also plan on learning and developing React Native mobile apps that would use the same Laravel backend?
Both alternatives work just fine, but it's easier to set up an api.mywebsite.com subdomain. Since you are going to also develop mobile apps that will connect to the API, that strengthens the argument of separating the API from the front-end app.

Deploy React JS bundle with Yii code base

I am looking for a solution to deploy me ReactJS application bundle with Yii(PHP) code base, I am already having an Yii application which is having frontend and backend both, but some of the page I have migrated into ReactJS application, I want to run both application on same environment,
I need help to configure the application and manage the routing also in the same fashion like old application will reload the page and ReactJS based code will run as client side.
Server: AWS
Technology: ReactJS + Yii (PHP)
Any suggestion !!!

Another front-end technology inqury - but using serverless backend

We have started to work with serverless technologies specifically with AWS Lambda and API Gateway using the serverless framework. We are working with Auth0 to manage authentication. Question is what is the best front-end technology we should use?
I think that we can build the front-end using S3 and cloudfront. The flexibility of each webpage or a set of webpages without any server sounds fantastic and simple, however I wanted to know of any pros and cons in building out web pages that use standard javascript ajax calls using S3 and cloudfront versus using other front-end technologies such as angularjs or vue?
tldr;: Should we build front-end pages using angularjs, vue, etc. or should we use S3 using pure AJAX calls? What are the pros and cons?
You should find hosting any application that uses a popular SPA framework via S3 is achievable. The fact you are using serverless for the API(s) that will be called from your SPA application makes no difference from the perspective of the SPA (client). The client is referencing a web endpoint only. For secured API endpoints, please look at Auth0's Resource API approach, where you would receive a JWT ID Token and JWT Access Token on successful authentication, and send the JWT Access Token with each request. More information on this on the Auth0 website together with samples illustrating how it all works.
Regarding choice on SPA framework / JS technology to use - here are a few useful links to help getting started:
AngularJS - https://auth0.com/docs/client-platforms/angularjs
AngularJS 2 - https://auth0.com/docs/client-platforms/angular2
EmberJS - https://auth0.com/docs/client-platforms/emberjs
EmberJS 2 - https://auth0.com/docs/client-platforms/ember2js
React - https://auth0.com/docs/client-platforms/react
jQuery - https://auth0.com/docs/client-platforms/jquery
Vanilla JS - https://auth0.com/docs/client-platforms/vanillajs
Hope your project is a success.

Best Practices For Django Web App + REST API Architecture as one project

I am working on my Django project which is going to be a Web App and REST Api for the mobile app.
I am using Django Rest Framework to build the API for the mobile app and it is going pretty good. I like it. For this part, I have a separate app within my Django project. Let's call it 'api'.
What I also want to do, is a web app. Let's call it 'webapp' in my Django project. So basically, web version of the mobile app, with a few different functionalities (e.g. different user/account management) for a slightly different part of the audience. Obviously, the majority of the models that I need, as well as logic are already there in the 'api' app. Also, I want to use Angularjs for the front end of the web app.
My question is what is the best path to take here? Should I create a separate app for my web app and copy the majority of views.py logic, which again will reference models and serializers from the 'api' app in the project? Or should I adjust my existing 'api' app to handle requests from both mobile phones and web app? Thank you.
You can follow link. I also follow that link when started angularjs, django and django-reset-framework.

Spring Security + Angular JS + Spring MVC Rest

I am trying to build a web application with the following frameworks:
Angular JS on the front end
REST Web Services in the backend using Spring MVC
I want to use Spring Security to authenticate all the requests going from Angular JS to Spring REST Web services. I also need to manage the session timeout/remember password etc. (All of the typical functionalities of a login functionality in a web app)
I have gone over hundreds of articles trying to find out how to do this but none of them is exactly serving the purpose I am asking for.
Any help on this (inline answer or external links) with detailed steps is highly appreciated.
(Note: I don't want to use Spring boot. Many tutorials including the one provided by Spring is using Spring boot.)
Finally found the way to do this. Clearly explained, step by step process to secure a Spring MVC based REST APIs using Spring Security
https://malalanayake.wordpress.com/2014/06/30/stateless-spring-security-on-rest-api/

Resources