Created the project from https://start.spring.io/ and added a dependency API gateway as below
plugins {
java
id("org.springframework.boot") version "3.3.0"
id("io.spring.dependency-management") version "1.1.5"
}
group = "fete.bird"
version = "0.0.1-SNAPSHOT"
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
repositories {
mavenCentral()
}
extra["springCloudVersion"] = "2023.0.2"
dependencies {
implementation("org.springframework.cloud:spring-cloud-starter-gateway-mvc")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
dependencyManagement {
imports {
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}")
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
Yaml configuration
spring:
application:
name: api-gateway
cloud:
gateway:
routes:
- id: course-route
uri: ${COURSE_SERVICE_URL:http://localhost:8081}
predicates:
- Path=/course/**
filters:
- AddRequestHeader=X-Tenant,acme
- AddResponseHeader=X-Genre, fantancy
Facing the issue 404
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sat Jun 08 20:40:28 AEST 2024
There was an unexpected error (type=Not Found, status=404).