title: Microsoft.AspNetCore.SpaProxy 6.0.1 - ASPNETCORE_HOSTINGSTARTUPASSEMBLIES - System.UriFormatException: Invalid URI: The URI is empty
body: <p>I get the following error when trying to add <code>Microsoft.AspNetCore.SpaProxy 6.0.1</code> NuGet on start:</p>
  <blockquote>
  <p>fail: Microsoft.AspNetCore.Server.Kestrel[13]
  Connection id &quot;X&quot;, Request id &quot;Y:00000001&quot;: An unhandled exception was thrown by the
  application.
  System.UriFormatException: Invalid URI: The URI is empty.
  at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions&amp; creationOptions)
  at System.Uri..ctor(String uriString)
  at Microsoft.AspNetCore.SpaProxy.SpaProxyMiddleware.Invoke(HttpContext
  context)
  at Microsoft.AspNetCore.Hosting.HostingApplication.ProcessRequestAsync(Context
  context)
  at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1
  application)</p>
  </blockquote>
  <p>In .NET 5 the following code was provided in <code>Startup.cs</code>.</p>
  <pre><code>app.UseSpa(spa =&gt;
  {
      spa.Options.SourcePath = &quot;ClientApp&quot;;
  
      if (env.IsDevelopment())
      {
          spa.UseReactDevelopmentServer(npmScript: &quot;start&quot;);
      }
  });
  </code></pre>
  <p>This is not present in .NET 6, instead <code>launchSettings.json</code> has an environment variable: <code>&quot;ASPNETCORE_HOSTINGSTARTUPASSEMBLIES&quot;: &quot;Microsoft.AspNetCore.SpaProxy&quot;</code></p>
  <p>I know it works since a new project using template <code>ASP.NET Core with React.js</code> and .NET 6 starts without a problem.</p>
  <p>What is needed to add <code>Microsoft.AspNetCore.SpaProxy</code> to an existing.NET 6 ASP.NET Core application with Create React App project with TypeScript?</p>
  <p><a href="https://create-react-app.dev/docs/adding-typescript/" rel="nofollow noreferrer">https://create-react-app.dev/docs/adding-typescript/</a></p>
  <p>I have tried to add the files <code>aspnetcore-https.js</code>, <code>aspnetcore-react.js</code>,<code>.env</code>, <code>.env.development</code> from working project.</p>
  <p>Edited <code>Program.cs</code> with these values:</p>
  <pre><code>app.UseStaticFiles();
  app.UseRouting();
  
  app.MapControllerRoute(
      name: &quot;default&quot;,
      pattern: &quot;{controller}/{action=Index}/{id?}&quot;);
  
  app.MapFallbackToFile(&quot;index.html&quot;);
  </code></pre>
  <p>Modified <code>package.json</code> to look like this:</p>
  <pre><code>&quot;prestart&quot;: &quot;node aspnetcore-https &amp;&amp; node aspnetcore-react&quot;,
  &quot;start&quot;: &quot;rimraf ./build &amp;&amp; react-scripts start&quot;,
  </code></pre>
  <p>I have installed <code>rimraf</code> and the command <code>npm run start</code> and <code>npm run build</code> works.</p>