T
T
Test-style2021-10-22 10:32:44
JavaScript
Test-style, 2021-10-22 10:32:44

Is it possible to redirect a POST request with Form-Data from a site to GitHub pages?

The task is as follows:
1) There is a website https://mysite.com deployed on GitHum pages (the domain is bound in CName)
2) There is an application with a back-end on node.js https://api.mysite.com deployed on AWS С2
3) There is a certain "Resource", the API of which notifies my site about any events.
And here's the catch:
This "Resource" at https://mysite.com sends a GET or POST method request containing the information I need in form-data. But I need this request on the api.mysite.com endpoint, and subdomains like https://api.mysite.com are not accepted. If the site were "lying" on a regular hosting, I would catch a resource request at https://mysite.com/endpoint.phpand send it to the desired https://api.mysite.com/endpoint/ . But what about GitHub pages? Is it possible to make a redirect pointing to the resource https://mysite.com/redirect.html ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nadim Zakirov, 2021-10-22
@zkrvndm

I didn't quite understand the question, but maybe this will help you:

var original = {
  open: XMLHttpRequest.prototype.open,
  send: XMLHttpRequest.prototype.send
};

XMLHttpRequest.prototype.open = function (method, url, async, user, password) {
  console.log(url);
  return original.open.call(this, method, url, async, user, password);
};

XMLHttpRequest.prototype.send = function (data) {
  console.log(data);
  return original.send.call(this, data);
};

You can replace the XMLHttpRequest function with your own and intercept all outgoing POST / GET requests. If desired, intercepted requests can be canceled and redirected to another address, which seems to be what you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question