I suggest that the destination property under routes could be a dynamic value to better use the Preview Environment
type: rewrite
source: /api/*
could be
type: rewrite
source: /api/*
fromService:
name: api-service
type: web
envVarKey: ENDER_EXTERNAL_HOSTNAME
Now the rewrite works for the Preview Environment