ionic-team / ionic-pwa-toolkit

Build lightning fast Progressive Web Apps with zero config and best practices built-in. Go from zero to production ready with Ionic and Stencil (Web Components).
MIT License
633 stars 74 forks source link

Profile page 404 when deployed, works on localhost #83

Closed arby50 closed 5 years ago

arby50 commented 5 years ago

Resources: Before submitting an issue, please consult our docs.

Stencil version: (run npm list @stencil/core from a terminal/cmd prompt and paste output below):

 "@stencil/core": "0.11.3"

I'm submitting a ... (check one with "x") [X ] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://stencil-worldwide.slack.com

Current behavior: app works on localhost as expected. When deployed, the "Profile Page" link button properly redirects to "/profile/ionic". However, refreshing the page produces a 404. Refreshing the same page on localhost does not.

Expected behavior: localhost and production refresh should both result in the refreshed page.

Steps to reproduce: clone and build the PWA toolkit npm start click "Profile Page" on resulting web page, view page Refresh page run 'npm run-script build' deploy the www folder to a production environment. click "Profile Page" on resulting web page, view page Refresh page<-404

Related code:

insert any relevant code here

Other information:

arby50 commented 5 years ago

after further investigating, this is an IIS issue. Or at least, I have the IIS solution. By adding a web.config to the root of the /www folder that contained the following rewrite:

<rewrite>
  <rules>
    <rule name="Main Rule" stopProcessing="true">
      <match url=".*" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
      </conditions>
      <action type="Rewrite" url="/index.html" />
    </rule>

  </rules>
</rewrite>

the web pages are viewable. I had to install the URLRewrite extension for IIS 7 also. Posting in case it helps someone else deploying to IIS.