クライアントに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>
...
残念ながら、アイデアは新鮮です。どんな助けでも素晴らしいでしょう。