polymerpolymer-2.xpolymer-starter-kit

How to set base URL for Polymer app


I want to configure my Polymer app to launch at this URL:

http://localhost:8081/polymer

Instead of the default:

http://localhost:8081

How do I set the base URL for the app?

I tried the following but couldn't seem to get it to work:

package.json

{
    "homepage": "http://localhost:8081/polymer"
}

Solution

  • Check out Polymer.rootPath and Polymer.importPath. https://www.polymer-project.org/2.0/docs/upgrade#urls-in-templates Somewhere in your app shell you should define Polymer.rootPath = 'somePath' (however you want to conjure it up), then elsewhere in your app if you need to utilize that path you use it like this:

    <iron-ajax url="[[rootPath]]api/somepath/somepath"></iron-ajax>