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

added errorRedirect to middleware opts #960

Closed

Conversation

thebells1111
Copy link

@thebells1111 thebells1111 commented Oct 24, 2019

errorRedirect is an object that can be passed to middleware that allows server side redirect on an error code.

errorRedirect: {errorStatus: 404, statusCode: 301, location: '/'}

The above object can be passed to allow a server side redirect to the specified location based on the errorStatus.
errorStatus can be a number, string, or array of number/string, and will default to 404
statusCode can be a number/string for the reroute status code; i.e. 301, 302, and will default to 301
location will be a string with the path to redirect to, and will default to '/'

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR relates to an outstanding issue, so please reference it in your PR, or create an explanatory one for discussion. In many cases features are absent for a reason.
  • This message body should clearly illustrate what problems it solves. If there are related issues, remember to reference them.
  • Ideally, include a test that fails without this PR but passes with it. PRs will only be merged once they pass CI. (Remember to npm run lint!)

Tests

  • Run the tests tests with npm test or yarn test)

thebells1111 added 2 commits October 24, 2019 11:59
errorRedirect is an object that can be passed to middleware that allows server side redirect on an error code.

errorRedirect: {errorStatus: 404, statusCode: 301, location: '/'} 

The above object can be passed to allow a server side redirect to the specified location based on the errorStatus.
errorStatus can be a number, string, or array of number/string, and will default to 404
statusCode can be a number/string for the reroute status code; i.e. 301, 302, and will default to 301
location will be a string with the path to redirect to, and will default to '/'
errorRedirect: {errorStatus: 404, statusCode: 301, location: '/'}

The above object can be passed to allow a server side redirect to the specified location based on the errorStatus.

errorStatus can be a number, string, or array of number/string, and will default to 404
statusCode can be a number/string for the reroute status code; i.e. 301, 302, and will default to 301
location will be a string with the path to redirect to, and will default to '/'
@thebells1111 thebells1111 deleted the thebells1111-error-redirect branch October 27, 2019 03:47
@thebells1111 thebells1111 restored the thebells1111-error-redirect branch October 27, 2019 04:04
@thebells1111 thebells1111 reopened this Oct 27, 2019
@benmccann
Copy link
Member

Thanks for putting together this PR! Sapper never had a good method of handling configuration, which made it difficult to know how to integrate this feature. However, that's been addressed in SvelteKit by adding a svelte.config.cjs file and adapters. I'm going to go ahead and close this PR since we won't be adding the feature to Sapper. You might like to check out SvelteKit instead

@benmccann benmccann closed this Mar 24, 2021
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 this pull request may close these issues.

2 participants