Communication between web app frontend and backend (authentication)

Cloud Texavie 71 Reputation points
2021-04-01T20:22:32.5+00:00

Hi,

I have deployed MERN stack web application using two different app service web app for the frontend (React) and the backend (Nodejs), each setup for continuous integration with a separate Github repo. As the frontend and backend are running on different domains, none of the functionalities involving cookies (e.g sending refresh tokens from the backend to the frontend) can be used. Would you have any recommendation on how to :

  1. Either deploy the frontend and backend on the same domain (so cookies can be used) without having to merge the code for both into a single repository
  2. Perform cross-domain authentication in a secure manner

Thanks

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,935 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 30,281 Reputation points Microsoft Employee Moderator
    2021-04-03T01:03:34.983+00:00

    Hi @Cloud Texavie ,

    You have some options at your disposal for setting up communication between your frontend and backend applications. One option is to restrict access to your backend Node app by adding both App Services to a Virtual Network and allowing the backend app to only see traffic on that VNET. If you don't want to restrict traffic, you can certainly enable authentication between both App Services through Bearer tokens through CORS. Below I've listed some docs that will help point you in the right direction.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.