X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-backend%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fric%2Fportal%2Fdashboard%2Fcontroller%2FHtml5PathsController.java;h=ed2e9053e83e3d26992df7ffe226aa4dcb4f4720;hb=a16f2d04fa1af4fe1ea993133a1d106e7fa1da3d;hp=abe3b16fc55be52a3ded84e2948e0f721f35e595;hpb=09df6d1bb8687f6f7970efbcac9bd3dc7b9503bb;p=portal%2Fric-dashboard.git diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/Html5PathsController.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/Html5PathsController.java index abe3b16f..ed2e9053 100644 --- a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/Html5PathsController.java +++ b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/Html5PathsController.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * O-RAN-SC * %% - * Copyright (C) 2019 AT&T Intellectual Property and Nokia + * Copyright (C) 2019 AT&T Intellectual Property * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +19,12 @@ */ package org.oransc.ric.portal.dashboard.controller; +import java.io.IOException; import java.lang.invoke.MethodHandles; +import java.net.URL; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,14 +49,19 @@ public class Html5PathsController { * https://stackoverflow.com/questions/44692781/configure-spring-boot-to-redirect-404-to-a-single-page-app * * @param request - * HttpServletRequest - * @return Forward directive to index.html + * HttpServletRequest + * @param response + * HttpServletResponse + * @throws IOException + * On error */ @RequestMapping(method = { RequestMethod.OPTIONS, RequestMethod.GET }, // path = { "/catalog", "/control", "/stats", "/user" }) - public String forwardAngularRoutes(HttpServletRequest request) { - logger.debug("forwardAngularRoutes: {}", request.getRequestURI()); - return "forward:/index.html"; + public void forwardAngularRoutes(HttpServletRequest request, HttpServletResponse response) throws IOException { + URL url = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), "/index.html"); + if (logger.isDebugEnabled()) + logger.debug("forwardAngularRoutes: {} redirected to {}", request.getRequestURI(), url); + response.sendRedirect(url.toString()); } }