Loading local resources statically to a vapor server


In a current project that I am working on, I need to setup Vapor inside the iOS Application. Vapor starts loading an html file and a sequence of other resources like css, scripts, fonts etc. The problem is that Javascript files seems not to be executed at all. I load each resource by:
req.fileio.streamFile(url) where the url is each file in my filesystem. My only problem is with the scripts, since everything else seems to load without any problem.
Any thoughts on that?

One question I would have is where are you loading the the l page from? Is it coming from the same URL or root URL? The reason I ask is that some aspects of browsers will not load JS that does not come from a safe considered source. Can you load the page/contents in a plain browser? Some browsers and I think Safari is one by default that is cautious in how it handles JS code. I don’t know the command personally but there may be some variables of flags passed to the function request to allow the JS to be loaded and executed.

I have loaded the html file from safari, chrome etc and the script that is referenced works perfectly. I do also make sure that my web view has javascript enabled (which is by default).
Also FYI the server gives me back response 200 code for the scripts, so they are not "Not Found" cases here. Just the scripts don't work at all.

Looking at the commands you’re using it looks like those on meant to load files, from various sources. Without understanding why your. Not just having the web view load the page via URL vs passing the fetched files I am not sure how to help you more. Hopefully somebody else here can help more.

Something tells me that your design tactic may not be the best. But I don’t know what would be better outside of loading the content within the web view.

Just to elaborate on a bit more. The steps that I follow are the following:

  1. I download a file containing web resources
  2. I save it to my file system etc under Documents or Caches
  3. I load a url to my web view from an html file and several dependencies start to load automatically by the server, css, js, fonts
  4. I have registered a route collection in vapor so when I capture the specific paths I do map these resources as server Responses. For examples, in index.html there is a main.js, a main.css and a pic.png so I return as Response in vapor return req.fileio.stream('Caches/DownloadedFile/main.js) and req.fileio.stream('Caches/DownloadedFile/main.js) and req.fileio.stream('Caches/DownloadedFile/pin.png).
    I hope it is more crystal clear right now.