How can I have HealthShare respect relative paths for javascript and css files that are referenced in the index.html file?

I am new to InterSystems.

I have set up a simple application in HealthShare.

Name: /testwebapp
CSP Files Physical Path: /Users/lakinducker/Documents/Dev/testwebapp/dist/testwebapp

In that directory are the following:
index.html
styles.3bb2a9d4949b7dc120a9.css
polyfills.c6871e56cb80756a5498.js
main.4ba7035983a7e3311083.js
runtime.ec2944dd8b20ec099bf3.js
favicon.ico
3rdpartylicenses.txt

If I go to http://localhost:57772/testwebapp, I get "Not found".

If I go to http://localhost:57772/testwebapp/index.html, I get the index.html file. However, it fails to get any of the javascript or css files that are referenced in the index.html.

In fact, I can see that it is trying to get them at..
http://localhost:57772/styles.3bb2a9d4949b7dc120a9.css

and not at...
http://localhost:57772/testwebapp/styles.3bb2a9d4949b7dc120a9.css

I am confused by this. There probably is a creative way to get around this. However, this is so strange to me, being someone new to InterSystems, that I thought I should ask.

Why is this happening? What do I need to change?

  • 0
  • 0
  • 100
  • 8
  • 1

Answers

If I go to http://localhost:57772/testwebapp, I get "Not found".

Yes, this is expected. The private instance of Apache which HealthShare runs on your port 57772 isn't set up to serve 'default' page(s).

As for your relative path problem, please show us what your index.html file looks like. Simplify it if you wish, but make sure you don't fix the problem as you do so!

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Testwebapp</title>
    <base href="/">

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/x-icon" href="favicon.ico">
    <link rel="stylesheet" href="styles.3bb2a9d4949b7dc120a9.css">
</head>

<body>
     <app-root></app-root>
<script type="text/javascript" src="runtime.ec2944dd8b20ec099bf3.js"></script><script type="text/javascript" src="polyfills.c6871e56cb80756a5498.js"></script><script type="text/javascript" src="main.4ba7035983a7e3311083.js"></script>
</body
</html>

What's the purpose of the  <base href="/">  in your <head> section? And if you remove it does your problem go away?

I don't think you need it at all. Take it out entirely and I'm betting your page will still work.

I will need to test that further. I believe that I need it for Angular. According to the Angular documentation, "Most routing applications should add a <base> element to the index.html as the first child in the <head> tag to tell the router how to compose navigation URLs."

I just tried it for another project and it also worked. 

Should I set up Apache to serve 'default' page(s)?