user12835700
user12835700

Reputation:

Redirect request to index?

In the react project, there are two index files; let's say index1.html and index2.html I have to redirect the request coming to index1 from another website to index2 and set some global variable if the website request came to index1. I totally have no idea how to solve this I don't have permission to change back-end code.

Upvotes: 0

Views: 82

Answers (1)

boen_robot
boen_robot

Reputation: 1538

You can set a cookie on the front end too. See react-cookie. And you get the referrer from document.referrer.

Of course, usual caveats with cookies and referrers apply:

  • Users may have configured their browser to not share referrer across origins, for privacy reasons.
  • Users may spoof the cookie (so don't use this for anything security related). There exist a concept called "signed cookies" (see cookie-parser middleware of express), but those require a server to sign them, and since you have no control of back end code, this is not for you.
  • Users may spoof the referrer (so don't use this for anything security related)

Upvotes: 1

Related Questions