0
App.js

    <PgRequest />   
    <BrowserRouter> 
        <Route exact path="/PgResponse" component={PgResponse}/>
</BrowserRouter> 

PgRequestComponent

class PgRequest extends Component{

ComponentDidMount()
{
this.submitForm();
}

submitForm=()=>{
document.form[0].method='post';
document.form[0].action='http://xxxxxx/tp/Pg';
document.form[0].submit();
}

render(){
return(
<div>
<form>
<input type='text' name='Name' />
<input type='text' name='ReturnUrl' value='http://localhost:3000/PgResponse' />
</form>
</div>
)
}
}

Now When Successfully Form Submitted to "http://xxxxxx/tp/Pg" then It redirects to my URL "localhost:3000/PgResponse"

Getting "Cannot POST /ComponentName"

in Network tab it shows 404 not Found but when i type URL in Browser it redirects me to that component i know its Get call when i type URL but how can i solve this so that it redirects to my component from Third party

Response from third Party: Screenshot

Return to my Component but Getting 404

  • 1
    When you are using BrowserRouter and you wish to navigate using url either directly or from a 3rd party app, you need to configure your server to return the home page of your app for all routes and then the client can perform the routing itself. You can refer this article for nodejs or webpack dev server: https://tylermcginnis.com/react-router-cannot-get-url-refresh/ – Shubham Khatri Sep 27 '19 at 05:32
  • i read article but still failed while i use as Suggested for server side Routing. – Mukul Khatter Sep 27 '19 at 06:57
  • I think your server can't handle POST method on `/PgResponse` endpoint, It's not a reactjs error, It look like a nodejs error. You can find more information here : https://stackoverflow.com/q/14902923/9150452 – Darkilen Sep 27 '19 at 13:49

0 Answers0