Skip to content

Commit 68bcdd5

Browse files
committed
fix: refresh redirect
jonashackt#154
1 parent ed22ed0 commit 68bcdd5

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

Diff for: backend/src/main/java/de/jonashackt/springbootvuejs/controller/BackendController.java

-8
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,4 @@ public User getUserById(@PathVariable("id") long id) {
5252
return SECURED_TEXT;
5353
}
5454

55-
// Forwards all routes to FrontEnd except: '/', '/index.html', '/api', '/api/**'
56-
// Required because of 'mode: history' usage in frontend routing, see README for further details
57-
@RequestMapping(value = "{_:^(?!index\\.html|api).*$}")
58-
public String redirectApi() {
59-
LOG.info("URL entered directly into the Browser, so we need to redirect...");
60-
return "forward:/";
61-
}
62-
6355
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package de.jonashackt.springbootvuejs.controller;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.stereotype.Controller;
6+
import org.springframework.web.bind.annotation.RequestMapping;
7+
8+
// https://github.com/jonashackt/spring-boot-vuejs/pull/154
9+
@Controller
10+
public class VueForwardController {
11+
12+
private static final Logger LOG = LoggerFactory.getLogger(VueForwardController.class);
13+
14+
// Forwards all routes to FrontEnd except: '/', '/index.html', '/api', '/api/**'
15+
// Required because of 'mode: history' usage in frontend routing, see README for further details
16+
@RequestMapping(value = "{_:^(?!index\\.html|api).*$}")
17+
public String redirectApi() {
18+
LOG.info("URL entered directly into the Browser, so we need to redirect...");
19+
return "forward:/";
20+
}
21+
22+
}

0 commit comments

Comments
 (0)