title: .NET Core 3.1 with ReactJs 16.9.0 - Run in IIS sub-folder
body: <p>I have a .NET Core 3.1 with ReactJs frontend (I am using the switch bionic framework) that I am trying to run in a sub folder (subapp) on IIS. Installing the app on IIS as a website works fine. The application runs without problems. But, when installing the application as a subapp under the IIS default page, will always give a 404 on any resources that react needs. This happens since the baseUrl used by React defaults to the root url.</p>
  <p>So far I have not found a way to change this behavior, short of adding the sub-folder name to the baseurl itself. This is not a solution for me, as this one application will be installed in at least 43 sub-folders under IIS on 1 server. I can't build and deploy 43+ apps just because the sub-folder has to be updated!</p>
  <p>Does anybody have ANY idea how I can get the react frontend to recognize the current url (which includes the sub-folder) in use and not just default to the root url?</p>
  <p>I have tried setting &quot;homepage&quot;: &quot;.&quot; and &quot;homepage&quot;: &quot;./&quot; in package.json, according to the post from 'gaearon' (<a href="https://github.com/facebook/create-react-app/issues/527" rel="nofollow noreferrer">https://github.com/facebook/create-react-app/issues/527</a>), but it had no affect.</p>
  <p>My config file (default.tsx) looks like this (edited on 2021/04/09):</p>
  <pre><code>import Project from '../src/globals/interfaces/Project';
  
  const isDevelopment = Object.is(process.env.NODE_ENV, 'development');
  
  const baseUrl = isDevelopment ? 'http://localhost:5105' : '.';
  
  const config: IConfigData&lt;Project, {}&gt; = {
    core: {
      i18n: {
        defaultLocale: 'en',
      },
    },
    project: {
      baseUrl,
    },
    runtime: {},
  };
  
  export default config;
  </code></pre>
  <p>My package.json:</p>
  <pre><code>{
    &quot;name&quot;: &quot;MyApp&quot;,
    &quot;version&quot;: &quot;3.4.2&quot;,
    &quot;description&quot;: &quot;My Application&quot;,
    &quot;license&quot;: &quot;Whatever&quot;,
    &quot;author&quot;: {
      &quot;name&quot;: &quot;Werner&quot;
    },
    &quot;config&quot;: {
      &quot;AppIcon&quot;: &quot;./src/assets/appIcon/logo.png&quot;,
      &quot;title&quot;: &quot;My App Title&quot;,
      &quot;devServer&quot;: {
        &quot;host&quot;: &quot;0.0.0.0&quot;,
        &quot;port&quot;: &quot;5170&quot;,
        &quot;https&quot;: false,
        &quot;publicPath&quot;: &quot;/&quot;
      },
      &quot;publicPath&quot;: &quot;&quot;,
      &quot;homepage&quot;: &quot;.&quot;,
      &quot;functionalTestBrowsers&quot;: [
        &quot;chrome&quot;,
        &quot;firefox&quot;,
        &quot;internet explorer&quot;,
        &quot;edge&quot;
      ]
    },
    &quot;scripts&quot;: {
      &quot;test&quot;: &quot;jest --no-cache&quot;,
      &quot;test:update&quot;: &quot;jest --updateSnapshot&quot;,
      &quot;start&quot;: &quot;webpack-dev-server --env.build=dev&quot;,
      &quot;start:4110&quot;: &quot;webpack-dev-server --env.build=dev --env.config=4110&quot;,
      &quot;start:4120&quot;: &quot;webpack-dev-server --env.build=dev --env.config=4120&quot;,
      &quot;start:4130&quot;: &quot;webpack-dev-server --env.build=dev --env.config=4130&quot;,
      &quot;start:4140&quot;: &quot;webpack-dev-server --env.build=dev --env.config=4140&quot;,
      &quot;start:4150&quot;: &quot;webpack-dev-server --env.build=dev --env.config=4150&quot;,
      &quot;start:legacy&quot;: &quot;webpack-dev-server --env.build=dev --env.legacy=true --env.REDUX_TOOLS=logger&quot;,
      &quot;start:swidget&quot;: &quot;webpack-dev-server --port 7070 --env.build=dev --env.swidget=true --env.legacy=true --env.REDUX_TOOLS=logger&quot;,
      &quot;start:host&quot;: &quot;webpack-dev-server --env.build=dev --env.legacy=true --env.exposed=true --env.REDUX_TOOLS=logger&quot;,
      &quot;build&quot;: &quot;webpack --env.build=prod --env.verbose=false&quot;,
      &quot;build:ci&quot;: &quot;webpack --env.build=prod --env.verbose=true --env.release=true&quot;,
      &quot;build:legacy&quot;: &quot;webpack --env.build=prod --env.legacy=true&quot;,
      &quot;build:host&quot;: &quot;webpack --env.build=prod --env.legacy=true --env.exposed=true&quot;,
      &quot;build:swidget&quot;: &quot;webpack --env.build=prod --env.swidget=true --env.legacy=true&quot;,
      &quot;build:multi&quot;: &quot;webpack --env.build=multi&quot;,
      &quot;build:test:functional&quot;: &quot;tsc -p test/functional/tsconfig.json&quot;,
      &quot;lint&quot;: &quot;nyr lint:eslint &amp;&amp; nyr lint:stylelint &amp;&amp; nyr lint:prettier&quot;,
      &quot;lint:staged&quot;: &quot;lint-staged&quot;,
      &quot;lint:eslint&quot;: &quot;eslint --ext ts,tsx src&quot;,
      &quot;lint:prettier&quot;: &quot;prettier --check \&quot;./**/*\&quot;&quot;,
      &quot;lint:stylelint&quot;: &quot;stylelint \&quot;src/**/*.(css|scss)\&quot; --syntax scss&quot;,
      &quot;lint:fix&quot;: &quot;nyr lint:fix:eslint &amp;&amp; nyr lint:fix:stylelint &amp;&amp; nyr lint:fix:postcss &amp;&amp; nyr lint:fix:prettier&quot;,
      &quot;lint:fix:prettier&quot;: &quot;prettier --write \&quot;./**/*\&quot;&quot;,
      &quot;lint:fix:postcss&quot;: &quot;postcss --config postcss.config.js --env sort-only --no-map --replace \&quot;src/**/*.(css|scss)\&quot;&quot;,
      &quot;lint:fix:stylelint&quot;: &quot;stylelint \&quot;src/**/*.(css|scss)\&quot; --syntax scss --fix&quot;,
      &quot;lint:fix:eslint&quot;: &quot;eslint --fix --ext ts,tsx src&quot;,
      &quot;clean&quot;: &quot;rimraf dist &amp;&amp; rimraf coverage&quot;,
      &quot;storybook&quot;: &quot;cross-env build=dev start-storybook -p 9001 -c .build/storybook&quot;,
      &quot;storybook:static&quot;: &quot;cross-env build=prod build-storybook -c .build/storybook -o dist/storybook&quot;,
      &quot;test:functional&quot;: &quot;run-p build:test:functional test:functional:selenium &amp;&amp; run-p --race start wdio&quot;,
      &quot;test:functional:headless&quot;: &quot;run-p build:test:functional test:functional:selenium &amp;&amp; run-p --race start wdio:headless&quot;,
      &quot;test:functional:selenium&quot;: &quot;selenium-standalone install --silent&quot;,
      &quot;wdio&quot;: &quot;wdio .build/wdio.conf.js&quot;,
      &quot;wdio:headless&quot;: &quot;cross-env WDIO_HEADLESS=true wdio .build/wdio.conf.js&quot;
    },
    &quot;husky&quot;: {
      &quot;hooks&quot;: {
        &quot;pre-commit&quot;: &quot;lint-staged&quot;,
        &quot;post-commit&quot;: &quot;git update-index --again&quot;
      }
    },
    &quot;repository&quot;: {
      &quot;type&quot;: &quot;git&quot;,
      &quot;url&quot;: &quot;Don't worry! Taken out for security!&quot;
    },
    &quot;engines&quot;: {
      &quot;node&quot;: &quot;&gt;=8.11.3&quot;,
      &quot;npm&quot;: &quot;&gt;=5.6.0&quot;
    },
    &quot;browserslist&quot;: [
      &quot;&gt; 1%&quot;,
      &quot;last 2 versions&quot;,
      &quot;Firefox ESR&quot;,
      &quot;ie &gt;= 11&quot;
    ],
    &quot;dependencies&quot;: {
      &quot;@daimler/material-ui-comps&quot;: &quot;0.0.4-release-84.0&quot;,
      &quot;@daimler/material-ui-theme&quot;: &quot;0.0.9&quot;,
      &quot;@daimler/typeface-daimler-cs-web&quot;: &quot;^1.0.0&quot;,
      &quot;@material-ui/core&quot;: &quot;^4.11.0&quot;,
      &quot;@material-ui/icons&quot;: &quot;^4.9.1&quot;,
      &quot;@material-ui/lab&quot;: &quot;^4.0.0-alpha.53&quot;,
      &quot;@switch/core&quot;: &quot;2.0.0-beta.2&quot;,
      &quot;@types/react-csv&quot;: &quot;^1.1.1&quot;,
      &quot;@types/react-router-dom&quot;: &quot;^5.1.3&quot;,
      &quot;@types/redux-logger&quot;: &quot;^3.0.7&quot;,
      &quot;axios&quot;: &quot;^0.19.0&quot;,
      &quot;core-js&quot;: &quot;~3.2.1&quot;,
      &quot;domtokenlist-shim&quot;: &quot;~1.2.0&quot;,
      &quot;file-saver&quot;: &quot;^2.0.2&quot;,
      &quot;inversify&quot;: &quot;~4.3.0&quot;,
      &quot;joi-browser&quot;: &quot;~13.4.0&quot;,
      &quot;jwt-decode&quot;: &quot;^2.2.0&quot;,
      &quot;material-table&quot;: &quot;^1.69.1&quot;,
      &quot;material-ui-dropzone&quot;: &quot;^3.2.1&quot;,
      &quot;react&quot;: &quot;~16.9.0&quot;,
      &quot;react-csv&quot;: &quot;^2.0.3&quot;,
      &quot;react-dom&quot;: &quot;~16.9.0&quot;,
      &quot;react-hot-loader&quot;: &quot;~4.12.11&quot;,
      &quot;react-promise-tracker&quot;: &quot;^2.0.5&quot;,
      &quot;react-redux&quot;: &quot;^7.2.0&quot;,
      &quot;react-router-dom&quot;: &quot;^5.1.2&quot;,
      &quot;react-switch&quot;: &quot;^5.0.1&quot;,
      &quot;react-table&quot;: &quot;^7.5.1&quot;,
      &quot;react-transition-group-v2&quot;: &quot;^4.3.0&quot;,
      &quot;redux&quot;: &quot;^4.0.5&quot;,
      &quot;redux-devtools-extension&quot;: &quot;^2.13.8&quot;,
      &quot;redux-logger&quot;: &quot;^3.0.6&quot;,
      &quot;redux-thunk&quot;: &quot;^2.3.0&quot;,
      &quot;regenerator-runtime&quot;: &quot;~0.13.3&quot;,
      &quot;tslib&quot;: &quot;~1.10.0&quot;,
      &quot;typesafe-actions&quot;: &quot;^5.1.0&quot;,
      &quot;universal-cookie&quot;: &quot;^4.0.3&quot;,
      &quot;whatwg-fetch&quot;: &quot;~3.0.0&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;@babel/core&quot;: &quot;~7.5.5&quot;,
      &quot;@babel/preset-env&quot;: &quot;~7.5.5&quot;,
      &quot;@babel/runtime&quot;: &quot;~7.5.5&quot;,
      &quot;@hot-loader/react-dom&quot;: &quot;~16.9.0&quot;,
      &quot;@storybook/addon-actions&quot;: &quot;~5.1.11&quot;,
      &quot;@storybook/addon-info&quot;: &quot;~5.1.11&quot;,
      &quot;@storybook/addon-knobs&quot;: &quot;~5.1.11&quot;,
      &quot;@storybook/addon-links&quot;: &quot;~5.1.11&quot;,
      &quot;@storybook/addons&quot;: &quot;~5.1.11&quot;,
      &quot;@storybook/cli&quot;: &quot;~5.1.11&quot;,
      &quot;@storybook/react&quot;: &quot;~5.1.11&quot;,
      &quot;@types/enzyme&quot;: &quot;~3.10.3&quot;,
      &quot;@types/jasmine&quot;: &quot;~3.4.0&quot;,
      &quot;@types/jest&quot;: &quot;~24.0.18&quot;,
      &quot;@types/jwt-decode&quot;: &quot;^2.2.1&quot;,
      &quot;@types/node&quot;: &quot;~12.0.0&quot;,
      &quot;@types/prop-types&quot;: &quot;~15.7.1&quot;,
      &quot;@types/react&quot;: &quot;~16.9.2&quot;,
      &quot;@types/react-dom&quot;: &quot;~16.9.0&quot;,
      &quot;@types/react-redux&quot;: &quot;^7.1.7&quot;,
      &quot;@types/react-test-renderer&quot;: &quot;~16.9.0&quot;,
      &quot;@types/storybook__addon-actions&quot;: &quot;~3.4.3&quot;,
      &quot;@types/storybook__addon-info&quot;: &quot;~4.1.2&quot;,
      &quot;@types/storybook__addon-knobs&quot;: &quot;~5.0.3&quot;,
      &quot;@types/storybook__addon-links&quot;: &quot;~3.3.5&quot;,
      &quot;@types/storybook__react&quot;: &quot;~4.0.2&quot;,
      &quot;@typescript-eslint/eslint-plugin&quot;: &quot;~2.0.0&quot;,
      &quot;@typescript-eslint/parser&quot;: &quot;~2.0.0&quot;,
      &quot;@wdio/cli&quot;: &quot;~5.12.4&quot;,
      &quot;@wdio/dot-reporter&quot;: &quot;~5.12.1&quot;,
      &quot;@wdio/jasmine-framework&quot;: &quot;~5.12.1&quot;,
      &quot;@wdio/local-runner&quot;: &quot;~5.12.4&quot;,
      &quot;@wdio/selenium-standalone-service&quot;: &quot;~5.12.1&quot;,
      &quot;@wdio/spec-reporter&quot;: &quot;~5.12.1&quot;,
      &quot;@wdio/sync&quot;: &quot;~5.12.3&quot;,
      &quot;babel-loader&quot;: &quot;~8.0.6&quot;,
      &quot;clean-webpack-plugin&quot;: &quot;~3.0.0&quot;,
      &quot;copy-webpack-plugin&quot;: &quot;~5.0.4&quot;,
      &quot;cross-env&quot;: &quot;~5.2.0&quot;,
      &quot;css-loader&quot;: &quot;~3.2.0&quot;,
      &quot;css-modules-typescript-loader&quot;: &quot;~3.0.0&quot;,
      &quot;cssjson&quot;: &quot;~2.1.3&quot;,
      &quot;duplicate-package-checker-webpack-plugin&quot;: &quot;~3.0.0&quot;,
      &quot;enzyme&quot;: &quot;~3.10.0&quot;,
      &quot;enzyme-adapter-react-16&quot;: &quot;~1.14.0&quot;,
      &quot;enzyme-to-json&quot;: &quot;~3.4.0&quot;,
      &quot;eslint&quot;: &quot;~6.2.1&quot;,
      &quot;eslint-config-prettier&quot;: &quot;~6.1.0&quot;,
      &quot;eslint-plugin-prettier&quot;: &quot;~3.1.0&quot;,
      &quot;eslint-plugin-react&quot;: &quot;~7.14.3&quot;,
      &quot;expose-loader&quot;: &quot;~0.7.5&quot;,
      &quot;fork-ts-checker-webpack-plugin&quot;: &quot;~1.5.0&quot;,
      &quot;html-webpack-multi-build-plugin&quot;: &quot;~1.0.0&quot;,
      &quot;html-webpack-plugin&quot;: &quot;~3.2.0&quot;,
      &quot;husky&quot;: &quot;~3.0.4&quot;,
      &quot;identity-obj-proxy&quot;: &quot;~3.0.0&quot;,
      &quot;imagemin-lint-staged&quot;: &quot;~0.4.0&quot;,
      &quot;jasmine&quot;: &quot;~3.4.0&quot;,
      &quot;jest&quot;: &quot;~24.9.0&quot;,
      &quot;lint-staged&quot;: &quot;~9.2.3&quot;,
      &quot;mini-css-extract-plugin&quot;: &quot;~0.8.0&quot;,
      &quot;mock-local-storage&quot;: &quot;~1.1.8&quot;,
      &quot;npm-run-all&quot;: &quot;~4.1.5&quot;,
      &quot;nyr&quot;: &quot;1.1.0&quot;,
      &quot;optimize-css-assets-webpack-plugin&quot;: &quot;~5.0.3&quot;,
      &quot;postcss&quot;: &quot;~7.0.17&quot;,
      &quot;postcss-cli&quot;: &quot;~6.1.3&quot;,
      &quot;postcss-extend&quot;: &quot;~1.0.5&quot;,
      &quot;postcss-import&quot;: &quot;~12.0.1&quot;,
      &quot;postcss-import-sync&quot;: &quot;~7.1.4&quot;,
      &quot;postcss-loader&quot;: &quot;~3.0.0&quot;,
      &quot;postcss-nested&quot;: &quot;~4.1.2&quot;,
      &quot;postcss-preset-env&quot;: &quot;~6.7.0&quot;,
      &quot;postcss-remove-prefixes&quot;: &quot;~1.2.0&quot;,
      &quot;postcss-sorting&quot;: &quot;~5.0.1&quot;,
      &quot;postcss-unprefix&quot;: &quot;~2.1.4&quot;,
      &quot;prettier&quot;: &quot;~1.18.2&quot;,
      &quot;react-ace&quot;: &quot;^7.0.4&quot;,
      &quot;react-docgen-typescript-loader&quot;: &quot;~3.1.1&quot;,
      &quot;react-test-renderer&quot;: &quot;~16.9.0&quot;,
      &quot;rimraf&quot;: &quot;~3.0.0&quot;,
      &quot;simple-progress-webpack-plugin&quot;: &quot;~1.1.2&quot;,
      &quot;style-loader&quot;: &quot;~1.0.0&quot;,
      &quot;stylelint&quot;: &quot;~10.1.0&quot;,
      &quot;stylelint-config-css-modules&quot;: &quot;~1.4.0&quot;,
      &quot;stylelint-config-recommended&quot;: &quot;~2.2.0&quot;,
      &quot;terser-webpack-plugin&quot;: &quot;~1.4.1&quot;,
      &quot;ts-jest&quot;: &quot;~24.0.2&quot;,
      &quot;ts-loader&quot;: &quot;~6.0.4&quot;,
      &quot;typescript&quot;: &quot;~3.5.3&quot;,
      &quot;url-loader&quot;: &quot;~2.1.0&quot;,
      &quot;webapp-webpack-plugin&quot;: &quot;~2.7.1&quot;,
      &quot;webpack&quot;: &quot;~4.39.2&quot;,
      &quot;webpack-cli&quot;: &quot;~3.3.7&quot;,
      &quot;webpack-dev-server&quot;: &quot;~3.8.0&quot;,
      &quot;webpack-merge&quot;: &quot;~4.2.1&quot;
    }
  }
  </code></pre>
  <p>Any help will be greatly appreciated.</p>