I had to make a pretty easy change so yours may be more complex than what I needed.
I need the user to view a piece of content that had the start on our front page so they could follow the flow from the start. So I had the "Preview" button in the Node Add and Node Edit form re-direct them to the front page.
I found the code I needed to adjust in the node.routing.yml in Core Module Node.
We had a custom module where I put the below code into the MyModule.routing.yml file. I changed the path to '/'. which is the path to the front page.
entity.node.preview:
path: '/'
defaults:
_controller: '\Drupal\node\Controller\NodePreviewController::view'
_title_callback: '\Drupal\node\Controller\NodePreviewController::title'
requirements:
_node_preview_access: '{node_preview}'
options:
parameters:
node_preview:
type: 'node_preview'
New note:
I need to create a special home page view to display some nodes that were not published yet so here's the code for that in my routing.yml
entity.node.preview:
path: '/event_previews/'
defaults:
_controller: '\Drupal\node\Controller\NodePreviewController::view'
_title_callback: '\Drupal\node\Controller\NodePreviewController::title'
requirements:
_node_preview_access: '{node_preview}'
options:
parameters:
node_preview:
type: 'node_preview'