Abhijatya Singh
Abhijatya Singh

Reputation: 642

Polymer starter kit routing issue

I am using polymer starter kit code and get the GUI with home, contact and user menu. I am using Java Dynamic Web Project in eclipse. So the base url is :

I have tried to set default base url in app.js file as:

If in routing.html, I make change like: -

page('/TestProject/', function() {
          app.route = 'home';
          setFocus(app.route);
        });

Nothing changes. But if I change in index.html:

<paper-menu class="app-menu" attr-for-selected="data-route" selected="[[route]]">
      <a data-route="home" href="{{baseUrl}}TestProject">
        <iron-icon icon="home"></iron-icon>
        <span>Home</span>
      </a>

Then the home url becomes:

http://localhost:8080/TestProject/#!/TestProject/

But it should be:

http://localhost:8080/TestProject/

or

http://localhost:8080/TestProject/#!/home

Guys where am I going wrong. Or where should I make change to achieve the home url.
Thanks a lot.

Upvotes: 2

Views: 210

Answers (1)

&#220;mit
&#220;mit

Reputation: 17499

Newer versions of the PSK have following section in the router.html:

// Removes end / from app.baseUrl which page.base requires for production
if (window.location.port === '') {  // if production
  page.base(app.baseUrl.replace(/\/$/, ''));
}

page('/',updateRedux, function() {
  page.redirect('/start');
});

page(app.baseUrl,updateRedux, function() {
  page.redirect('/start');
});

Upvotes: 1

Related Questions