Angular routes redirecting to base URL on refresh in WebLogic server

34 views Asked by At

I have an Angular application deployed on a WebLogic server. The application is inside an EAR file. I have defined routes like /about and /exceptions in my Angular application.

The issue I’m facing is that whenever I try to enter the URL directly in the browser or refresh the page, it’s redirecting me to the base URL. I want it to stay on the same page (like baseurl/exceptions or baseurl/about) even after a page refresh.

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"% <%@ page import="javax.servlet.http.HttpServletResponse" %> <%@ page import="java.io.IOException" %> <%@ page import="java.net.URLEncoder" %> <%
// Get the referrer URL
String referrer = request.getHeader("Referer");
System.out.print("referrer:" + request);
System.out.print("referrer:" + response);

// If referrer is not available, set a default URL
if (referrer == null || referrer.isEmpty()) {
    referrer = "/tool";
}

// Redirect to the referrer
try {
    response.sendRedirect(response.encodeRedirectURL(referrer));
} catch (IOException e) {
    e.printStackTrace();
} %>

How can I configure my server or Angular application to stay on the same page after a refresh?

For example: if I refresh on /about it should be stay on /about and not redirect to baseurl.

I added this 404.jsp because whenever I was refreshing the page it was giving me 404.jsp

0

There are 0 answers