Skip to content

Commit

Permalink
feat(roc-package-web-app-react): Customize status code for redirects (#…
Browse files Browse the repository at this point in the history
…33)

Possible to change using `runtime.redirectStatusCode` / `--runtime-redirectStatusCode`. Will default to `302` which is the same as the default behaviour before.
  • Loading branch information
forberg authored and dlmr committed Feb 9, 2018
1 parent 3ce8676 commit 214765b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ export default function reactRouter({
});

if (redirect) {
if (rocConfig.runtime.redirectStatusCode) {
this.status = rocConfig.runtime.redirectStatusCode;
}
this.redirect(redirect);
} else {
this.status = status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default {
style: [],
},
ssr: true,
redirectStatusCode: 302,
template: {
path: undefined,
name: 'main.html',
Expand Down
17 changes: 16 additions & 1 deletion packages/roc-package-web-app-react/src/config/roc.config.meta.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
import { isString, isBoolean, isPath, isArray, isObject, notEmpty, required, oneOf, isFunction } from 'roc/validators';
import {
isString,
isBoolean,
isPath,
isArray,
isObject,
notEmpty,
required,
oneOf,
isFunction,
isInteger,
} from 'roc/validators';

export default {
settings: {
Expand Down Expand Up @@ -59,6 +70,10 @@ export default {
description: 'If server side rendering should be enabled.',
validator: required(isBoolean),
},
redirectStatusCode: {
description: 'Status code for redirects.',
validator: required(isInteger),
},
template: {
path: {
description: 'A directory, or array of directories, where the template for the application ' +
Expand Down

0 comments on commit 214765b

Please sign in to comment.