I am currently building a website that utilizes Java for the backend and Angular for the frontend. I have encountered a scenario where external websites may transmit data to my site via POST form submissions. For example,
▼ General
Request URL: https://myangularwebsite/
Request Method: POST
...
▼ Request Headers
Content-Type: application/x-www-form-urlencoded
Host: myangularwebsite
Origin: https://externalwebsite
Referer:
https://externalwebsite/send.form?id=0
...
▼ Form data
ID: 0000000
TIME: 2017.06.04 11:53:58
SIGNATURE: ...geirgmGKFGJWR...
...
At this point, I need to find a way to capture the form data in Angular, then send or redirect it to the backend for signature validation before receiving the response back in Angular to continue working on the website.
I attempted to test the process by posting to my site using Postman, but received an error message stating Cannot POST /
.
While I am familiar with handling GET requests and URL query parameters in Angular, I believe I need to delve into processing POST requests based on the headers observed in the 'Network' section of Chrome DevTools when transferring from externalwebsite
to myangularwebsite
.
Would it be advisable to create a specific route in the backend, such as .../api/external
, and instruct these external sites to use this link instead of directly submitting forms to the homepage of my Angular-powered site?
I have come across a related question ( How to read form post data in Angular 2 typescript? ) which touches on a similar topic, however, employing PHP doesn't seem like the right path for me given that the current version of the site is already built using PHP.