Created
April 30, 2021 11:44
-
-
Save puttpotsawee/37b5bfa0ebadecfe24c54a400601ca24 to your computer and use it in GitHub Desktop.
Run-time integration via iframes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Feed me!</title> | |
</head> | |
<body> | |
<h1>Welcome to Feed me!</h1> | |
<iframe id="micro-frontend-container"></iframe> | |
<script type="text/javascript"> | |
const microFrontendsByRoute = { | |
'/': 'https://browse.example.com/index.html', | |
'/order-food': 'https://order.example.com/index.html', | |
'/user-profile': 'https://profile.example.com/index.html', | |
}; | |
const iframe = document.getElementById('micro-frontend-container'); | |
iframe.src = microFrontendsByRoute[window.location.pathname]; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment