Skip to content

Commit

Permalink
fix: null pointer when CORS maxAge is not specified (#2133)
Browse files Browse the repository at this point in the history
fix nullpointer

Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
  • Loading branch information
zhaohuabing committed Nov 1, 2023
1 parent defed57 commit 35c4fea
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/xds/translator/cors.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ func patchRouteWithCORSConfig(route *routev3.Route, irRoute *ir.HTTPRoute) error
allowMethods = strings.Join(irRoute.CORS.AllowMethods, ", ")
allowHeaders = strings.Join(irRoute.CORS.AllowHeaders, ", ")
exposeHeaders = strings.Join(irRoute.CORS.ExposeHeaders, ", ")
maxAge = strconv.Itoa(int(irRoute.CORS.MaxAge.Seconds()))
if irRoute.CORS.MaxAge != nil {
maxAge = strconv.Itoa(int(irRoute.CORS.MaxAge.Seconds()))
}

routeCfgProto := &corsv3.CorsPolicy{
AllowOriginStringMatch: allowOrigins,
Expand Down

0 comments on commit 35c4fea

Please sign in to comment.