เรามีแอปสำหรับองค์กรที่ใช้ Angular 2 สำหรับลูกค้า แต่ละของลูกค้าของเรามี URL ที่เป็นเอกลักษณ์ของตนเองอดีต: และhttps://our.app.com/customer-one https://our.app.com/customer-twoขณะนี้เรามีความสามารถในการตั้งค่าแบบไดนามิกโดยใช้<base href...> document.locationผู้ใช้จึงนิยมhttps://our.app.com/customer-twoและ<base href...>ตั้งค่าเป็น/customer-two... สมบูรณ์แบบ!
ปัญหาคือถ้าผู้ใช้เป็นตัวอย่างที่https://our.app.com/customer-two/another-pageและรีเฟรชหน้าหรือพยายามกด url นั้นโดยตรง<base href...>ได้รับการตั้งค่า/customer-two/another-pageและทรัพยากรไม่พบ
เราได้ลองทำสิ่งต่อไปนี้แล้ว แต่ไม่เกิดประโยชน์:
<!doctype html>
<html>
<head>
<script type='text/javascript'>
var base = document.location.pathname.split('/')[1];
document.write('<base href="https://stackoverflow.com/' + base + '" />');
</script>
...
น่าเสียดายที่เรามีแนวคิดใหม่ ๆ ความช่วยเหลือใด ๆ ที่น่าอัศจรรย์