spring-cloud / spring-cloud-gateway

An API Gateway built on Spring Framework and Spring Boot providing routing and more.
http://cloud.spring.io
Apache License 2.0
4.55k stars 3.33k forks source link

try_files functionality like nginx #900

Closed SidneyLann closed 5 years ago

SidneyLann commented 5 years ago

try_files functionality like it in nginx to support react

spencergibb commented 5 years ago

A single sentence about a feature in some other server I don't know about isn't helpful. Please describe in detail the feature you're twisting l requesting.

SidneyLann commented 5 years ago

in react, access index page, like http://localhost/index.html, when click the menu and rout to another page like /mgt/supplierList, if I click the fresh button of the browser, 404 exists because the server side has no /mgt/supplierList, however, nginx has the try_files directive to solve this problem like below: location / { root /home/sidney/html; index index.html; try_files $uri /index.html; }

if the uri not exists in server side, so redirect to /index.html

SidneyLann commented 5 years ago

spring.cloud.gateway.routes[13].id=index2 spring.cloud.gateway.routes[13].uri=forward:///mgt/index.html spring.cloud.gateway.routes[13].predicates[0]=Path=/mgt

these lines do the thing for try_files, no need to implement now, thanks.