mirror of
https://github.com/usatiuk/y.git
synced 2025-10-28 18:37:47 +01:00
pain and suffering
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
"start": "parcel",
|
"start": "parcel",
|
||||||
"build": "parcel build"
|
"build": "parcel build"
|
||||||
},
|
},
|
||||||
|
"publicUrl": "/app",
|
||||||
"browserslist": "> 0.5%, last 2 versions, not dead",
|
"browserslist": "> 0.5%, last 2 versions, not dead",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"jwt-decode": "^4.0.0",
|
"jwt-decode": "^4.0.0",
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ import { Chat } from "./Chat";
|
|||||||
import { ChatEdit } from "./ChatEdit";
|
import { ChatEdit } from "./ChatEdit";
|
||||||
import { Haters } from "./Haters";
|
import { Haters } from "./Haters";
|
||||||
|
|
||||||
const router = createBrowserRouter([
|
const router = createBrowserRouter(
|
||||||
|
[
|
||||||
{
|
{
|
||||||
path: "/",
|
path: "/",
|
||||||
loader: async () => {
|
loader: async () => {
|
||||||
@@ -127,7 +128,9 @@ const router = createBrowserRouter([
|
|||||||
},
|
},
|
||||||
action: signupAction,
|
action: signupAction,
|
||||||
},
|
},
|
||||||
]);
|
],
|
||||||
|
{ basename: "/app" },
|
||||||
|
);
|
||||||
|
|
||||||
export function App() {
|
export function App() {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -3,7 +3,14 @@
|
|||||||
import { jwtDecode } from "jwt-decode";
|
import { jwtDecode } from "jwt-decode";
|
||||||
import { isError } from "./dto";
|
import { isError } from "./dto";
|
||||||
|
|
||||||
const apiRoot: string = "http://localhost:8080";
|
declare const process: {
|
||||||
|
env: {
|
||||||
|
NODE_ENV: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const apiRoot: string =
|
||||||
|
process.env.NODE_ENV == "production" ? "/" : "http://localhost:8080";
|
||||||
|
|
||||||
let token: string | null;
|
let token: string | null;
|
||||||
|
|
||||||
|
|||||||
50
server/src/main/java/com/usatiuk/tjv/y/server/WebConfig.java
Normal file
50
server/src/main/java/com/usatiuk/tjv/y/server/WebConfig.java
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package com.usatiuk.tjv.y.server;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.http.CacheControl;
|
||||||
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
import org.springframework.web.servlet.resource.ResourceResolver;
|
||||||
|
import org.springframework.web.servlet.resource.ResourceResolverChain;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableWebMvc
|
||||||
|
public class WebConfig implements WebMvcConfigurer {
|
||||||
|
static class AppResourceResolver implements ResourceResolver {
|
||||||
|
@Override
|
||||||
|
public Resource resolveResource(HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain) {
|
||||||
|
ClassPathResource res = new ClassPathResource("/app/" + requestPath);
|
||||||
|
if (res.exists()) return res;
|
||||||
|
ClassPathResource indexRes = new ClassPathResource("/app/index.html");
|
||||||
|
if (indexRes.exists()) return indexRes;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String resolveUrlPath(String resourcePath, List<? extends Resource> locations, ResourceResolverChain chain) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addViewControllers(ViewControllerRegistry registry) {
|
||||||
|
registry.addRedirectViewController("/app/", "/app/index.html");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
|
registry.addResourceHandler("/app/**")
|
||||||
|
.setCacheControl(CacheControl.maxAge(Duration.ofDays(365)))
|
||||||
|
.resourceChain(true)
|
||||||
|
.addResolver(new AppResourceResolver());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -59,6 +59,7 @@ public class WebSecurityConfig {
|
|||||||
.authorizeHttpRequests((authorize) -> authorize
|
.authorizeHttpRequests((authorize) -> authorize
|
||||||
.requestMatchers(mvc.pattern(HttpMethod.POST, "/person")).permitAll()
|
.requestMatchers(mvc.pattern(HttpMethod.POST, "/person")).permitAll()
|
||||||
.requestMatchers(mvc.pattern(HttpMethod.POST, "/token")).permitAll()
|
.requestMatchers(mvc.pattern(HttpMethod.POST, "/token")).permitAll()
|
||||||
|
.requestMatchers(mvc.pattern("/app/**")).permitAll()
|
||||||
.requestMatchers(mvc.pattern("/swagger-ui*/**")).permitAll()
|
.requestMatchers(mvc.pattern("/swagger-ui*/**")).permitAll()
|
||||||
.requestMatchers(mvc.pattern("/v3/**")).permitAll()
|
.requestMatchers(mvc.pattern("/v3/**")).permitAll()
|
||||||
.requestMatchers(mvc.pattern("/error")).permitAll()
|
.requestMatchers(mvc.pattern("/error")).permitAll()
|
||||||
|
|||||||
Reference in New Issue
Block a user