I'm having a weird behavior with my angular 7 application. Everytime i hit refresh, it loses the track of routes and gives me a 404. I've read in a lot of places about configuring the web.config to fix the issue, but even with it configured I can't get rid of this behavior.
web.config
<rules>
<rule name="Angular Routes" 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="/" />
</rule>
</rules>
module configuration
@NgModule({
imports: [
AppRoutingModule,
SharedModule,
HttpClientModule,
AuthModule,
StoreModule.forRoot(reducers, { metaReducers }),
EffectsModule.forRoot(effects),
StoreRouterConnectingModule,
environment.development ? StoreDevtoolsModule.instrument() : []
],
declarations: [AppComponent],
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
{ provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
{ provide: RouterStateSerializer, useClass: CustomSerializer }],
bootstrap: [AppComponent]
})
export class AppModule {}
I also have this section <base href="/" />
in the header of my index.html file
在文件夹dist内,您应该有一个带有项目名称的文件夹,尝试将该文件夹的内容直接移到dist下方
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.