Injecting Auth Header into Cross-Origin-Request from browser

I have a web app written in javascript and C#. The web app contains an iframe in one of its pages. I need to embed an external web site (controlled by the client, and protected by an API Key) into this iframe.

Before I chose to mark this as doable I did a test, downloading requestly chrome extension, and injecting the API Key into the Authorization header whenever the Cross-Origin-Request is made by chrome to the external web site. The site loaded into the iframe perfecto. no complications. I’ve also done this with Fiddler as an experiment. The Cross-Origin-Request is made by chrome, and Fiddler then intercepts the request, injects the Auth header and viola, iframe loads the site seamlessly!

Please note, the external URL is not an endpoint that returns data, but simple a web page that displays a dashboard. And this web page is secured by an API Key, which can only be passed in through an Authorization Header. So this makes it somewhat a little more tricky.

Given the above, We cannot expect every client to download and configure requestly, or Fiddler for that matter, and update the API keys should they be updated. This is definately a no go for us. So I need to have this done in our code (javascript, or C#), so I’ve tried:

  • Service Workers (but this is not allowed for Cross-Origin-Requests)
  • I’ve looked at creating a URL rewrite rule in IIS but got stuck here and spent way to much time on this so I don’t think this will work either
  • Creating a simple javascript fetch statement I don’t think will work either as this fetches the content from the external site as if it were static, which breaks navigability on the site in addition to not loading styles e.t.c. You can see this when doing it through postman.
  • I’ve tried InterceptRequestsJS, but this does not seem to work. will have a look again just to be sure.

So it almost feels near impossible a task. Is this something doable? When I enable requestly and look at the network traffic, the first call to the web site issues a 307 redirect with what looks like a Auth cookie. The Auth cookie is then stored in the browser under the external web site domain, then a second call is made to the “Location” response header of the 307 redirect, which then calls the site again but this time, the browser says, “hey, here’s the cookie, send that along” and viola! the site loads.

Given the above, I will need to mimick this either by:

  • Using a javascript fetch statement (but wrestling with CORS errors at the moment) and then hope that the cookie is consumed by chrome.
  • Or use a nice tool that someone wrote that can do all this for me, almost like a ‘mini’ requestly package for javascript, for which I have searched but struggling to find something that works. (Will keep on searching…)

Has anyone had the same requirements? I would preferrably want to use C# as a type of proxy for this so that I don’t expose the API Key on the front end. However, javascript is probably then also an option.

Any help would be greatly appreciated.
Thanks

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật