Skip to content

Commit

Permalink
fix: null pointer when CORS maxAge is not specified (envoyproxy#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>
(cherry picked from commit 35c4fea)
Signed-off-by: Arko Dasgupta <arko@tetrate.io>
  • Loading branch information
zhaohuabing authored and arkodg committed Nov 1, 2023
1 parent 1178128 commit 4ee83d2
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 4ee83d2

Please sign in to comment.