feat: block all entries to enter details that miss the required params
This commit is contained in:
196
next.config.js
196
next.config.js
@@ -72,38 +72,172 @@ const nextConfig = {
|
||||
|
||||
// https://nextjs.org/docs/app/api-reference/next-config-js/redirects#header-cookie-and-query-matching
|
||||
redirects() {
|
||||
// Param checks needs to be split as Next.js handles everything
|
||||
// in the missing array as AND, therefore they need to be separate
|
||||
// to handle when one or more are missing.
|
||||
//
|
||||
// Docs: all missing items must not match for the redirect to be applied.
|
||||
return [
|
||||
// {
|
||||
// ----------------------------------------
|
||||
// Uncomment when Team Explorer has deployed
|
||||
// the select room submission
|
||||
// ----------------------------------------
|
||||
// source: "/:lang/hotelreservation/(select-bed|breakfast|details|payment)",
|
||||
// destination: "/:lang/hotelreservation/select-rate",
|
||||
// missing: [
|
||||
// {
|
||||
// key: "hotel",
|
||||
// type: "query",
|
||||
// value: undefined,
|
||||
// },
|
||||
// {
|
||||
// key: "fromDate",
|
||||
// type: "query",
|
||||
// value: undefined,
|
||||
// },
|
||||
// {
|
||||
// key: "toDate",
|
||||
// type: "query",
|
||||
// value: undefined,
|
||||
// },
|
||||
// {
|
||||
// key: "room",
|
||||
// type: "query",
|
||||
// value: undefined,
|
||||
// },
|
||||
// ],
|
||||
// permanent: false,
|
||||
// },
|
||||
{
|
||||
// ----------------------------------------
|
||||
// hotel (hotelId) param missing
|
||||
// ----------------------------------------
|
||||
source:
|
||||
"/:lang/hotelreservation/(select-bed|breakfast|details|payment)",
|
||||
destination: "/:lang/hotelreservation/select-rate",
|
||||
missing: [
|
||||
{
|
||||
key: "hotel",
|
||||
type: "query",
|
||||
value: undefined,
|
||||
},
|
||||
],
|
||||
permanent: false,
|
||||
},
|
||||
{
|
||||
// ----------------------------------------
|
||||
// hotel (hotelId) param has to be an integer
|
||||
// ----------------------------------------
|
||||
source:
|
||||
"/:lang/hotelreservation/(select-bed|breakfast|details|payment)",
|
||||
destination: "/:lang/hotelreservation/select-rate",
|
||||
missing: [
|
||||
{
|
||||
key: "hotel",
|
||||
type: "query",
|
||||
value: "^[0-9]+$",
|
||||
},
|
||||
],
|
||||
permanent: false,
|
||||
},
|
||||
{
|
||||
// ----------------------------------------
|
||||
// fromDate param missing
|
||||
// ----------------------------------------
|
||||
source:
|
||||
"/:lang/hotelreservation/(select-bed|breakfast|details|payment)",
|
||||
destination: "/:lang/hotelreservation/select-rate",
|
||||
missing: [
|
||||
{
|
||||
key: "fromDate",
|
||||
type: "query",
|
||||
value: undefined,
|
||||
},
|
||||
],
|
||||
permanent: false,
|
||||
},
|
||||
{
|
||||
// ----------------------------------------
|
||||
// fromDate param has to be a date
|
||||
// ----------------------------------------
|
||||
source:
|
||||
"/:lang/hotelreservation/(select-bed|breakfast|details|payment)",
|
||||
destination: "/:lang/hotelreservation/select-rate",
|
||||
missing: [
|
||||
{
|
||||
key: "fromDate",
|
||||
type: "query",
|
||||
value: "^([12]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01]))$",
|
||||
},
|
||||
],
|
||||
permanent: false,
|
||||
},
|
||||
{
|
||||
// ----------------------------------------
|
||||
// toDate param missing
|
||||
// ----------------------------------------
|
||||
source:
|
||||
"/:lang/hotelreservation/(select-bed|breakfast|details|payment)",
|
||||
destination: "/:lang/hotelreservation/select-rate",
|
||||
missing: [
|
||||
{
|
||||
key: "toDate",
|
||||
type: "query",
|
||||
value: undefined,
|
||||
},
|
||||
],
|
||||
permanent: false,
|
||||
},
|
||||
{
|
||||
// ----------------------------------------
|
||||
// toDate param has to be a date
|
||||
// ----------------------------------------
|
||||
source:
|
||||
"/:lang/hotelreservation/(select-bed|breakfast|details|payment)",
|
||||
destination: "/:lang/hotelreservation/select-rate",
|
||||
missing: [
|
||||
{
|
||||
key: "toDate",
|
||||
type: "query",
|
||||
value: "^([12]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01]))$",
|
||||
},
|
||||
],
|
||||
permanent: false,
|
||||
},
|
||||
{
|
||||
// ----------------------------------------
|
||||
// room[0].adults param missing
|
||||
// ----------------------------------------
|
||||
source:
|
||||
"/:lang/hotelreservation/(select-bed|breakfast|details|payment)",
|
||||
destination: "/:lang/hotelreservation/select-rate",
|
||||
missing: [
|
||||
{
|
||||
key: "room[0].adults",
|
||||
type: "query",
|
||||
value: undefined,
|
||||
},
|
||||
],
|
||||
permanent: false,
|
||||
},
|
||||
{
|
||||
// ----------------------------------------
|
||||
// room[0].adults param has to be an integer
|
||||
// ----------------------------------------
|
||||
source:
|
||||
"/:lang/hotelreservation/(select-bed|breakfast|details|payment)",
|
||||
destination: "/:lang/hotelreservation/select-rate",
|
||||
missing: [
|
||||
{
|
||||
key: "room[0].adults",
|
||||
type: "query",
|
||||
value: "^[0-9]+$",
|
||||
},
|
||||
],
|
||||
permanent: false,
|
||||
},
|
||||
{
|
||||
// ----------------------------------------
|
||||
// room[0].ratecode param missing
|
||||
// ----------------------------------------
|
||||
source:
|
||||
"/:lang/hotelreservation/(select-bed|breakfast|details|payment)",
|
||||
destination: "/:lang/hotelreservation/select-rate",
|
||||
missing: [
|
||||
{
|
||||
key: "room[0].ratecode",
|
||||
type: "query",
|
||||
value: undefined,
|
||||
},
|
||||
],
|
||||
permanent: false,
|
||||
},
|
||||
{
|
||||
// ----------------------------------------
|
||||
// room[0].roomtype param missing
|
||||
// ----------------------------------------
|
||||
source:
|
||||
"/:lang/hotelreservation/(select-bed|breakfast|details|payment)",
|
||||
destination: "/:lang/hotelreservation/select-rate",
|
||||
missing: [
|
||||
{
|
||||
key: "room[0].roomtype",
|
||||
type: "query",
|
||||
value: undefined,
|
||||
},
|
||||
],
|
||||
permanent: false,
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user