I have two different flutter web application hosted on different server running on different domain. Both application has sign in features. Now our requirement changed and we have to serve one application with single domain. What I am trying to do it to load second flutter web application as iFrame. I am able to load it successfully but problem is it is showing sign in screen again. To avoid it I want to pass data through iFrame to child application so I can handle sign in things.
I tried so many approach like window.postMessagae(), MethodChannel but not working.
Is there any way to achieve this? How to achieve this as microfrontend?
2
Answers
I can feel your pain. One general approach is to use JWT for authentication and pass the token from the parent application to the child application.
Here’s a great post:
https://dev.to/carminezacc/user-authentication-jwt-authorization-with-flutter-and-node-176l
here’s a package: https://pub.dev/packages/jwt_decoder
You could pass the token you’ve generated in your main application to the url you’re using in the iFrame, for example,
"https://yourdomain.com/?token=${token}"
, so you can use this token in your secondary application to sign in the user