Remove Gateway service and configuration
- Delete Gateway module, associated Spring Boot application, and related configuration (`GatewayApplication.java`, `application.yml`, and `pom.xml`). - Remove Gateway references in `docker-compose.yml`, `.gitlab-ci.yml`, and `backend/pom.xml`. - Update backend services to directly handle requests under `/api` prefix (e.g., `/api/customers`, `/api/contact`). - Adjust frontend contact route to connect directly to the server, replacing gateway references with server URLs.
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="GatewayApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
|
||||
<option name="envFilePaths">
|
||||
<option value="$PROJECT_DIR$/gateway.env" />
|
||||
</option>
|
||||
<module name="gateway" />
|
||||
<selectedOptions>
|
||||
<option name="environmentVariables" />
|
||||
</selectedOptions>
|
||||
<option name="SPRING_BOOT_MAIN_CLASS" value="dev.rheinsw.gateway.GatewayApplication" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="dev.rheinsw.gateway.*" />
|
||||
<option name="ENABLED" value="true" />
|
||||
</pattern>
|
||||
</extension>
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
@@ -7,7 +7,6 @@ build_backend:
|
||||
artifacts:
|
||||
paths:
|
||||
- backend/common/target/
|
||||
- backend/gateway/target/
|
||||
- backend/discovery/target/
|
||||
- backend/server/target
|
||||
expire_in: 1 hour
|
||||
@@ -21,18 +20,6 @@ docker_common:
|
||||
needs:
|
||||
- build_backend
|
||||
|
||||
docker_gateway:
|
||||
extends: .docker-build-template
|
||||
variables:
|
||||
IMAGE_NAME: gateway
|
||||
COMMON_IMAGE: "$CI_REGISTRY/$CI_PROJECT_PATH/common"
|
||||
WORKDIR_PATH: backend
|
||||
DOCKERFILE_PATH: Dockerfile.app
|
||||
BUILD_FOLDER: "gateway/target"
|
||||
MAIN_CLASS: dev.rheinsw.gateway.GatewayApplication
|
||||
needs:
|
||||
- build_backend
|
||||
- docker_common
|
||||
|
||||
docker_server:
|
||||
extends: .docker-build-template
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>dev.rheinsw</groupId>
|
||||
<artifactId>backend</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<groupId>dev.rheinsw.backend</groupId>
|
||||
<artifactId>gateway</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven.compiler.plugin.version}</version>
|
||||
<configuration>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/libs</outputDirectory>
|
||||
<includeScope>runtime</includeScope>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.github.ben-manes.caffeine/caffeine -->
|
||||
<dependency>
|
||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||
<artifactId>caffeine</artifactId>
|
||||
<version>3.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Tools -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.rheinsw</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -1,15 +0,0 @@
|
||||
package dev.rheinsw.gateway;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @author Thatsaphorn Atchariyaphap
|
||||
* @since 04.05.25
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class GatewayApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GatewayApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
server:
|
||||
port: 8080
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: gateway
|
||||
main:
|
||||
web-application-type: reactive # Set the application type to reactive
|
||||
|
||||
cloud:
|
||||
gateway:
|
||||
routes:
|
||||
- id: server
|
||||
uri: http://${SERVER_HOST:localhost}:8081
|
||||
predicates:
|
||||
- Path=/api/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
- PreserveHostHeader
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
<modules>
|
||||
<module>common</module>
|
||||
<module>gateway</module>
|
||||
<module>server</module>
|
||||
</modules>
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/contact")
|
||||
@RequestMapping("/api/contact")
|
||||
public class ContactController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ContactController.class);
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.UUID;
|
||||
* @since 02.07.25
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/customers")
|
||||
@RequestMapping("/api/customers")
|
||||
@RequiredArgsConstructor
|
||||
public class CustomerController extends AbstractController {
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* @since 04.05.25
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/mail")
|
||||
@RequestMapping("/api/mail")
|
||||
@RequiredArgsConstructor
|
||||
public class MailController {
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.UUID;
|
||||
* @since 12.07.25
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/projects")
|
||||
@RequestMapping("/api/projects")
|
||||
@RequiredArgsConstructor
|
||||
public class ProjectController extends AbstractController {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
server:
|
||||
port: 8081
|
||||
port: 8080
|
||||
|
||||
spring:
|
||||
application:
|
||||
|
||||
@@ -1,18 +1,11 @@
|
||||
services:
|
||||
gateway:
|
||||
image: registry.boomlab.party/rheinsw/rheinsw-mono-repo/gateway
|
||||
container_name: gateway
|
||||
env_file:
|
||||
- ./gateway.env
|
||||
restart: on-failure
|
||||
networks:
|
||||
- rheinsw-net
|
||||
|
||||
server:
|
||||
image: registry.boomlab.party/rheinsw/rheinsw-mono-repo/server
|
||||
container_name: server
|
||||
env_file:
|
||||
- ./server.env
|
||||
ports:
|
||||
- "8080:8080"
|
||||
restart: on-failure
|
||||
networks:
|
||||
- rheinsw-net
|
||||
|
||||
@@ -3,10 +3,10 @@ import {NextRequest, NextResponse} from 'next/server'
|
||||
const HCAPTCHA_SECRET = process.env.HCAPTCHA_SECRET ?? ''
|
||||
const SHARED_API_KEY = process.env.SHARED_API_KEY ?? ''
|
||||
|
||||
// Detect whether to use localhost or Docker gateway
|
||||
const useLocalGatewayEnv = process.env.USE_LOCAL_GATEWAY
|
||||
const useLocalGateway = useLocalGatewayEnv?.toLowerCase() === 'true'
|
||||
const gatewayHost = useLocalGateway ? 'http://localhost:8080' : 'http://gateway:8080'
|
||||
// Detect whether to use localhost or Docker server
|
||||
const useLocalServerEnv = process.env.USE_LOCAL_SERVER
|
||||
const useLocalServer = useLocalServerEnv?.toLowerCase() === 'true'
|
||||
const serverHost = useLocalServer ? 'http://localhost:8080' : 'http://server:8080'
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
try {
|
||||
@@ -42,7 +42,7 @@ export async function POST(req: NextRequest) {
|
||||
// }
|
||||
|
||||
// Step 2: Forward to backend service
|
||||
const backendRes = await fetch(`${gatewayHost}/api/contact`, {
|
||||
const backendRes = await fetch(`${serverHost}/api/contact`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Origin: origin,
|
||||
|
||||
Reference in New Issue
Block a user