#azure storage static website

1 messages · Page 1 of 1 (latest)

undone elbow
#

Is it possible to serve a static web app in azure storage but also respect the subdirectories and relative path structures for links?

acoustic cave
#

yes, as long as there is no dynamic content, and the links are relative

undone elbow
#

Thanks for assisting here. It seems I'm have trouble with the relative links. I have a directory as follows, which is uploaded to the $web directory in storage account.

  • test
    • index.html
    • style.css
  • index.html

where /test/index.html references the style.css like so link rel="stylesheet" href="./style.css">. Say my static domain is test.web.core.windows.net when i access test.web.core.windows.net/test the style is being fetch from test.web.core.windows.net/style.css rather than test.web.core.windows.net/test/style.css

Am i doing something wrong here?

acoustic cave
#

are you 110% SURE the href is DOT slash and not just slash style.css

undone elbow
#

I tried both and neither worked. It seems to just resolve to the root with no relative addressing.

acoustic cave
undone elbow
#

Yea i saw that. If it helps visualize things, i'm essentially just uploading the files in this zip into $web directory of an azure storage.

acoustic cave
#

ok, let me upload to a storage acct

#

#WorksForMe ... 😄

undone elbow
#

!!

#

interesting, were all three of the styles sheet links able to load properly?

acoustic cave
#

i didnt try, i commented 2 of them out

#

check the source

#

just left one there

undone elbow
acoustic cave
#

ahh... yeah, i renamed it to index2 and referenced it directly just so there wasnt a chance of a conflict

#

/test is technically a file ref, not a directory ref

#

so when default index.html is returned, it doesnt look to the browser like its in a subfolder

#

just use /test/style.css in the reference and you should be good

undone elbow
#

Ah got it. Don't think it would be feasible to do the last suggestion as its a zip file that I'm downloading from an external source to load into an iframe, and would be challenging to fix all the references. But i don't think i need to set the Index document name at all, can just access the page with the .html extension which should work.

#

Out of curiosity, I'm guessing there isn't a way to do it like this https://ktwebstorage.z33.web.core.windows.net/test while keeping the relative paths?

acoustic cave
#

this isnt a "azure static website" issue in that case, its the browser trying to pull a relative link

#

and to it the relative link to "/test" is /

#

if the link was "/test/" then it would be different

#

imagine you have an html file in the root folder actually called "test"

#

now can you see how the browser thinks it needs to get the stylesheet from the root and not the folder?

undone elbow
#

😯 That makes sense! Interesting, haven't thought it through like that before. Thanks for the explanation.

#

Thanks for all the help on this!