Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Support redirecting to absolute URL from this.redirect in preload #490

Closed
antony opened this issue Oct 23, 2018 · 1 comment · Fixed by #503
Closed

Support redirecting to absolute URL from this.redirect in preload #490

antony opened this issue Oct 23, 2018 · 1 comment · Fixed by #503

Comments

@antony
Copy link
Member

antony commented Oct 23, 2018

As discussed in the Sapper discord.

In a preload method inside a page, you can call this.redirect to redirect the page before it renders.

this.redirect(301, 'some/url')

It would be advantageous (for instance, in the case of adding SEO mappings for legacy urls), if we could redirect to external urls (i.e. another website).

One possible way of doing this would be:

this.redirect(301, 'https://www.some.other/url', true)

where the third parameter defines whether the url is absolute (true) or relative (false).

@antony antony changed the title Support redirecting to absolute URL from res.redirect on server Support redirecting to absolute URL from this.redirect in preload Oct 23, 2018
Rich-Harris added a commit that referenced this issue Oct 27, 2018
redirect to external URLs
@Rich-Harris
Copy link
Member

Fixed in 0.24!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants