0
votes

I have a bunch of .htm files, which have navigations within to other .htm files. I have uploaded them to Azure blob container. I want to open the first .htm file with SAS token, and would like to access others through it. However when this is happens, the sas token is no longer there for the others and therefore, I am not able to access the other files.

I tried getting the sas initially for the entire blob container, However the issue still persists, as in the url itself when I navigate to another using the link in the first .htm, it will not contain the sas token.

As there any workaround for this that will allow them to open? Other than changing the permission for the container to allow anonymous access.

1
How are you navigating between multiple .htm files?Hemant Halwai
Its just an anchor tag with the name of the other htm file in href. Theres a lot of these as it is part of a guide. I was just given the resources, didnt develop any of the files.NAKDeveloper
Your anchor tag contain href= "./filename.htm" OR href= "URL/filename.htm" ?Hemant Halwai
just href="filename.htm" is what I have seen.NAKDeveloper

1 Answers

0
votes

Since your anchor tag contain name of the files(i.e relative path) and not the URL, these htmls cannot be linked directly with eachother through Azure BLOB as BLOBS can be accessed with URL. Since you mentioned you have lot of such html files, I would suggest you to host a static website as just only one i.e starting .htm file will need change.

For authentication purpose, you can add a custom javascript code, in your starting [first] .htm file, where you can authenticate if the SAS token is present and correct. Something like this

<script>
function validateToken(){
    const currentUrl = window.location.href;
    const SASToken = '?' + 'yourSASToken';
    if(currentUrl) {
        const token = currentUrl.split('.htm')[1];
        if(!token || token.length === 0 ||  token !== SASToken){
            window.location = 'error';
        }
    }
}
</script>
<body onload="validateToken();">
<H1>First.htm</H1>
<a href="second.htm">Next</a>
</body>