We can share a route with another space using the cf share-route command. To move an app to another space, you can share routes with that space to prevent downtime during the transition. Rather than deleting the route in the original space and re-creating the route in the new space, we can share the route with the new space and map it to the app running in that space.
After "cf share-route" or "cf move-route" one route into a target org/space, the "cf push" fails with an error message, "Routes cannot be mapped to destinations in different spaces".
Pushing app sample-app to org org2 / space space1 as user...
Applying manifest file /home/ubuntu/index/manifest.yaml...
Updating with these attributes...
---
applications:
- name: sample-app
disk-quota: 1024M
health-check-type: http
health-check-http-endpoint: /
memory: 200M
+ default-route: true
buildpacks:
php_buildpack
health-check-invocation-timeout: 10
For application 'sample-app': Routes cannot be mapped to destinations in different spaces
FAILED
This issue happens only if when the target space name is the same with the source space name.
It is recommended to use different space names with "cf move-route" or "cf share-route" as a workaround. This issue is addressed internally and more information will be disclosed once the fix is available.