Angular'da build ettikten sonra sunucuya atınca routing sorunu
Angular'da build ettikten sonra sunucuya atınca routing sorunu çözümü için
1) ng build --base-href .
2).htaccess dosyası oluşturulup
Apache için
RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
# If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html
IIS için webconfig içerisine
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<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="./index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Nginx için
try_files $uri $uri/ /index.html;
yapmanız yeterlidir.
Angular'da build ettikten sonra sunucuya atınca routing sorunu