0

After production build I have deployed project in to tomcat server. When i open it in browser it is opening perfect and routing also working. But when I refresh the browser showing error 404. My tomcat folder structures is below

build path
tomcat
  --webapps
     --prod
           --assets
           --css
           --js
           index.html

http://localhost:8080/prod/

seed.config.ts

APP_BASE = argv['base'] || '/';

index.html

<base href="/prod/">

This problem iam facing only on refresh the page. Please anyone help me on this issue. Thanks in advance

GCP
  • 69
  • 3
  • 10

1 Answers1

0

It sounds like you're using HTML5 routing (without the #) so you need some server config in order for all the requests (minus the files and folders) to be routed to the index.html. Something like the below in an .htaccess file of the root folder should fix it :-

RewriteEngine On 
Options FollowSymLinks

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /#/$1 [L]

Edit:- The above is for an Apache server, when it comes to a Tomcat server the same applies - you need to redirect all traffic to your index.html file. I could write it out but Andrew Mairose's answer details how to do this and so no need to re-invent the wheel.

Community
  • 1
  • 1
Joe Keene
  • 2,175
  • 21
  • 27
  • I have written .htaccess file also. **sample.htaccess** `RewriteEngine On RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d RewriteRule ^ – [L] RewriteRule ^ /index.html [L]` How to use this htaccess file please explain – GCP Apr 28 '17 at 05:16
  • Hello, updated my answer as .htaccess won't work on a Tomcat server - apologies. – Joe Keene Apr 28 '17 at 06:03
  • How to resolve this issue. Please anyone help me on this. – GCP Apr 28 '17 at 06:13