Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update shortner endpoint to look at request headers origin instead of host #7840

Closed
wants to merge 2 commits into from
Closed

Conversation

rahul-rahul-sp
Copy link
Contributor

CATEGORY

Choose one

  • Bug Fix
  • [ x] Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

SUMMARY

Update shortner url for to look at the origin request header instead of host.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TEST PLAN

Tested locally

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

REVIEWERS

@graceguo-supercat
Copy link

Hi @rahul-rahul-sp what is purpose of this code change?

@rahul-rahul-sp
Copy link
Contributor Author

hi @graceguo-supercat , it is a question i asked here. i wanted to get the community's take on this.the PR is just to show the change.

#7839

@@ -1008,7 +1008,7 @@ def shortner(self):
db.session.add(obj)
db.session.commit()
return Response(
"{scheme}://{request.headers[Host]}/r/{obj.id}".format(
"{request.headers[origin]}/r/{obj.id}".format(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am ok to use ORIGIN instead of HOST, why remove {scheme} part?

Also please check the error message in unit test, you probably need to find a way to get HTTP_ORIGIN header

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will double check on the schema but in my local testing it was getting added automatically.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin

@rahul-rahul-sp
Copy link
Contributor Author

follow up PR:
#7876

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants