title: Delphi TIdHTTPServer: not allowed to load local resourse from remote device
body: <p>I'm making a VCL Forms Application with a TIdHTTPServer on the main form and a CommandGet of the IdHTTPServer procedure: </p>
  
  <pre><code>procedure TForm6.IdHTTPServerCommandGet(AContext: TIdContext;
    ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
  var
    indexStream: TFileStream;
    path, indexPath: string;
  begin
    AResponseInfo.CharSet := 'UTF-8';
    path := GetCurrentDir.Remove(GetCurrentDir.Length - Length('Win32\Debug'));
    ARequestInfo.Document := path + 'scripts/script1.js';
    ARequestInfo.Document := path + 'scripts/script2.js';
  
    if pos('profile', ARequestInfo.UnparsedParams) &gt; 0 then
    begin
      indexPath := path + 'index.html';  
      AResponseInfo.ContentStream := TFileStream.Create(indexPath, fmOpenReadWrite);
    end;
  end;
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>procedure TForm6.IdHTTPServerCommandGet(AContext: TIdContext;
     ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
  var
    applicationDirectory: string;
  begin
    AResponseInfo.CharSet := 'UTF-8';
    AResponseInfo.FreeContentStream := True;
    applicationDirectory := ExtractFilePath(Application.ExeName)
      .Remove(ExtractFilePath(Application.ExeName).Length -
      Length('Win32\Debug') - 1);
    AResponseInfo.ContentStream := TFileStream.Create(applicationDirectory +
       'scripts/script1.js', fmOpenRead or fmShareDenyWrite);
    AResponseInfo.ContentStream := TFileStream.Create(applicationDirectory +
       'scripts/script2.js', fmOpenRead or fmShareDenyWrite);
  
    if pos('profile&amp;userName=', ARequestInfo.UnparsedParams) &gt; 0 then
    begin
      AResponseInfo.ContentStream :=
         TFileStream.Create(applicationDirectory + 'index.html', fmOpenRead);
    end;
    // other requests
  end;
  </code></pre>
  
  <p>Here is the content of index.html:</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Profile&lt;/title&gt;
      &lt;script type="text/javascript" src="[app-path]/scripts/script1.js "&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="[app-path]/scripts/script2.js "&gt;&lt;/script&gt;
      &lt;meta http-equiv="cache-control" content="no-cache"&gt;
      &lt;meta http-equiv="pragma" content="no-cache"&gt;
    &lt;/head&gt;
    &lt;body&gt;
    &lt;!-- Page content --&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When I start the application and access <code>http://localhost/?profile&amp;userName=testUser</code> it works fine but when I start the application and type in other computer's chrome browser <code>http://{my-ip4-address}/?profile&amp;userName=testUser</code> I get two messages: 'Not allowed to load local resource: file:///{app_path}/scripts/script1.js', 'Not allowed to load local resource: file:///{app_path}/scripts/script2.js. The content of the HTML page is visible.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Based on the comments and answer <code>index.html</code> changed to</p>
  
  <pre><code> &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Profile&lt;/title&gt;
      &lt;script type="text/javascript" src="/scripts/script1.js "&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="/scripts/script2.js "&gt;&lt;/script&gt;
      &lt;meta http-equiv="cache-control" content="no-cache"&gt;
      &lt;meta http-equiv="pragma" content="no-cache"&gt;
    &lt;/head&gt;
    &lt;body&gt;
    &lt;!-- Page content --&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Editing my code like this I can access files but the problem is that the content of script1.js is same as the content of script2.js. Any idea how to send the files correctly.</p>