score:0
at least when using vercel, you can archive this by repeating the parameters from the has
in the destination
but leaving the value empty.
e.g.:
{
source: '/page',
has: [
{
type: 'query',
key: 'foo'
}
],
destination: '/page/:foo?foo=',
permanent: true
}
parameters that already exit in the destination
won't be copied over and parameters with an empty value in the destination
will be removed completely.
score:4
you can use middleware.
just parse the query parameter yourself and add redirection.
store a file _middleware.ts
below the pages directory:
export async function middleware(req: nextrequest) {
const { pathname } = req.nexturl;
if (// your-thing )
return nextresponse.redirect(//your-url);
return nextresponse.next();
}
maybe there is a different way, i don't know, but it doesn't matter.
Source: stackoverflow.com
Related Query
- How to drop the query parameters after a redirect with NextJS?
- How to make a GraphQL lazy query with Apollo client after the first query is successful
- How to redirect to home page from custom 404 page with locale in the url nextjs
- How to update the Redux store after Apollo GraphQL query returns
- How to fix the white screen after build with create-react-app?
- How to correctly redirect after catching authentication failure with Apollo and React
- How do you update Formik initial values with the react context api values after an AJAX request?
- How to redirect to correct client route after social auth with Passport (react, react-router, express, passport)
- How to server side redirect to other page without reloading the page and still keeping the url in Nextjs app?
- How to redirect with react-router while preserving initial query parameters?
- How do I update the grapqhl cache with urql upon a mutation, where the initial query response does not include the required __typename?
- How to display the result of Select query on list with ReactJS?
- How do I redirect user to another page after submit the form?
- How to retrieve the parameter after a hash (#) with React Router and useParams hook?
- How do I make mutliple graphql queries with the same query using react-apollo?
- After I delete AutoComplete'option in FormItem, How could I clear input with the deleted value?
- How to redirect user back to initially-requested page after authentication with React-Router v6?
- How do i make a react app redirect to the login page after registration?
- How to reset to initial coordinates after some drag operation with the library react-cytoscape.js
- How do I modify the route parameters sent as props with React Router?
- React Query with TypeScript - how to force the rule that the query key always needs to be an array
- How to get the querystring parameters with Astro
- React Router with Meteor: How to remove code param from URL after redirect from OAuth without reload
- I am trying to animate an object with css in react and change the animation (timing) dynamically, how can I set the style after animation end?
- How to inherit query parameters on Link Component without knowledge of the location object
- How to get the query params inside getServerSideProps in nextjs
- How to solve the problem with types in NextJs (Typescript)?
- How to pass additional information using auth0-js (to redirect the user after login)
- How can I conditionally redirect to a page after the axios response in react?
- How can I make react render the new state modifications after I have updated the state with hooks and context
More Query from same tag
- add props to route component
- Yup schema: How to add new line in error message
- How to change color/borderColor of concrete country in react-leaflet
- assert that only single child is passed in `this.props.children`
- how to stop the side effect of React.useEffect?
- React Native: Getting the position of an element
- reactJs App js - passing incoming data as props
- Saving array of objects in state and passing it to return to display it on web page in react
- Firebase cloud functions direct app calling on client
- How to write an onChange function in this case?
- Uncaught TypeError: Cannot read properties of undefined (reading 'source') in CartItem
- No 'Access-Control-Allow-Origin in reactJS
- React: Perform action, only once, when html element is clicked
- Closing conditionally a bootstrap modal panel if login is successful
- Async component snapshot using Jest and Redux
- Stop user from scrolling more than 1 element at once
- How to convert the following properties from CSS to Mui?
- How can we call onNewRequest property in onBlur in AutoComplete Material-UI?
- react-datepicker and react-hook-forms: required not working
- Node.js endpoint with knex does not return anything. Front-end stucks without reply
- How to find nested element in jest by value of attribute
- Is there a better way of adding divs dynamically to a existing element?
- React hook arguments cause infinite rerendering
- How to get a code coverage report with react-create-app?
- Using setState inside useEffect on updating forms
- TypeError: Cannot read property 'handleSubmit' of undefined
- How to set a video current time on page load in HTML5 then add a seek listener synchronously
- Cannot read properties of undefined (reading 'map') - useQuery
- Typescript React: Do I have to specify arguments for the super class constructor. And what arguments would that be?
- How can I make my div tab to disabled cannot click in