React – history push throwing error: Failed to execute ‘pushState’ on ‘History’

I have a page on the URL:http://localhost:10001/track/8311c15a-7f7f-47ff-b81a-6f6904ad191c/my-form where I have a form. After the form is submitted I am using react’s router history to redirect to a success page

const MyComponent = ({match, location, history}: RouteComponentProps

const onSubmit = () => {
  history.push(`/${baseUrl}/success`)
}

But, when I try to do so, I get an error:

Uncaught DOMException: Failed to execute 'pushState' on 'History': A history state object with URL 'http://track/8311c15a-7f7f-47ff-b81a-6f6904ad191c/success' cannot be created in a document with origin 'http://localhost:10001' and URL 'http://localhost:10001/track/8311c15a-7f7f-47ff-b81a-6f6904ad191c/my-form'.

It is the first time I have encountered this error. What am I doing wrong here?