title: How to set baseUrl in Polymer Starter Kit?
body: <p>How to set baseUrl in Polymer Starter Kit(light version)?</p>
  
  <p>(similar: <a href="https://stackoverflow.com/questions/42090070/serving-polymer-app-to-a-path-not-at-root">Serving Polymer App to a /path not at root</a>)</p>
  
  <p>I want to run it in subfolder
  (dl and unzipped PSK there, server is xampp): </p>
  
  <blockquote>
    <p><a href="http://localhost/test/psk/app/" rel="nofollow noreferrer">http://localhost/test/psk/app/</a></p>
  </blockquote>
  
  <p>When I go to that URL, app is redirecting to: </p>
  
  <blockquote>
    <p><a href="http://localhost/" rel="nofollow noreferrer">http://localhost/</a></p>
  </blockquote>
  
  <p>with this note:</p>
  
  <blockquote>
    <p>Can't find: <a href="http://localhost/test/psk/app/#!/test/psk/app/" rel="nofollow noreferrer">http://localhost/test/psk/app/#!/test/psk/app/</a>. Redirected
    you to Home Page Ok</p>
  </blockquote>
  
  <p>There are no console errors, app work fine except the URL problem.</p>
  
  <p>Here are <code>app.js</code>:</p>
  
  <pre><code>// Sets app default base URL
    app.baseUrl = '/';
  
    if (window.location.port === '') {  // if production
      // Uncomment app.baseURL below and
      // set app.baseURL to '/your-pathname/' if running from folder in production
      // app.baseUrl = '/polymer-starter-kit/';
  
  
     // If this is baseURL:
     //app.baseUrl = 'http://localhost/test/psk/app/';
     //Then click on the menu -  reloads the page with 404 URL:
     //http://localhost/test/psk/app/users
    }
    ...
  </code></pre>
  
  <p>and <code>routing.html</code></p>
  
  <pre><code>&lt;script src="../bower_components/page/page.js"&gt;&lt;/script&gt;
  &lt;script&gt;
    window.addEventListener('WebComponentsReady', function() {
  
        console.log('routing.html');
  
      // We use Page.js for routing. This is a Micro
      // client-side router inspired by the Express router
      // More info: https://visionmedia.github.io/page.js/
  
      // Removes end / from app.baseUrl which page.base requires for production
      if (window.location.port === '') {  // if production
        page.base(app.baseUrl.replace(/\/$/, ''));
         console.log("app.baseUrl");
         console.log(app.baseUrl);
      }
  
      // Middleware
      function scrollToTop(ctx, next) {
        app.scrollPageToTop();
        next();
      }
  
      function closeDrawer(ctx, next) {
        app.closeDrawer();
        next();
      }
  
      function setFocus(selected){
        document.querySelector('section[data-route="' + selected + '"] .page-title').focus();
      }
  
      // Routes
      page('*', scrollToTop, closeDrawer, function(ctx, next) {
        next();
      });
  
      page('/', function() {
        app.route = 'home';
        setFocus(app.route);
      });
  
      page(app.baseUrl, function() {
        app.route = 'home';
        setFocus(app.route);
      });
  
      page('/users', function() {
        app.route = 'users';
        setFocus(app.route);
      });
  
      page('/users/:name', function(data) {
        app.route = 'user-info';
        app.params = data.params;
        setFocus(app.route);
      });
  
      page('/contact', function() {
        app.route = 'contact';
        setFocus(app.route);
      });
  
      // 404
      page('*', function() {
        app.$.toast.text = 'Can\'t find: ' + window.location.href  + '. Redirected you to Home Page';
        app.$.toast.show();
        page.redirect(app.baseUrl);
      });
  
      // add #! before urls
      page({
        hashbang: true
      });
  
    });
  &lt;/script&gt;
  </code></pre>