Skip to content

paulwoods/gateway-and-clients

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gateway-and-clients

example showing a spring boot gateway, and 2 react clients

We want to access each client though these URLS:

When we run the application (on localhost), we use these ports:

  • gateway: 8080
  • client1: 5173
  • client2: 5174

Spring Boot Gateway

The gateway is a spring boot app, with this dependency:

implementation 'org.springframework.cloud:spring-cloud-starter-gateway'

The configuration file will list each client. The clients are run on different ports, and have a path to uniquely define the URL to each.

server:
  port: 8080

spring:
  cloud:
    gateway:
      routes:
        - id: client1
          uri: http://localhost:5173
          predicates:
            - Path=/client1/**
          filters:
            - StripPrefix=0
        - id: client2
          uri: http://localhost:5174
          predicates:
            - Path=/client2/**
          filters:
            - StripPrefix=0

React Clients

The React clients are Vite projects, with react and typescript. Update vite.config.ts, and add the base:

export default defineConfig({
    plugins: [react()],
    base: "/client1"
})

About

example showing a spring boot gateway, and 2 react clients

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published