Added a prefix config setting to the previewHandler to add a prefix to the redirect response #379
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
By adding a prefix setting to the previewHandler, it will be possible to allow a prefix to the redirect uri.
This will solve the issue where a same url is used in different roots.
An example of the configuration:
Because our preview routes are separate for every root, we can simply create a single
/api/preview/[root]/route.ts
file to catch all our preview routes. With the extra prefix config setting of the previewHandler, we can now pass the desired prefix for each root.This will redirect our preview routes as follows:
We can accommodate each root separately within our app folder, even though both slugs for the different roots are the same (path-of-my-entry).
Without the extra prefix config setting both preview urls would be redirected to
/path-of-my-entry
. This will make it impossible to know in which root they are. This pull request solves this issue.