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

- replaces content-type header by accept to match HTTP and avoid CORS preflight #783

Merged
merged 1 commit into from
Jan 8, 2021

Conversation

baywet
Copy link
Member

@baywet baywet commented Dec 14, 2020

Overview

The auto-complete feature is currently using the Content-Type request header.
Not only this is the wrong header to specify which format you want in return from the server, it also forces a CORS preflight which double the load per auto-complete "run" on the service, degrading the end user experience.
This pull request corrects the header usage.

Demo

image
image

Wrong:

Invoke-WebRequest -Uri "https://graphexplorerapi.azurewebsites.net/openapi?url=/&style=geautocomplete&graphVersion=v1.0" `
-Headers @{
"method"="GET"
  "authority"="graphexplorerapi.azurewebsites.net"
  "scheme"="https"
  "path"="/openapi?url=/&style=geautocomplete&graphVersion=v1.0"
  "user-agent"="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
  "accept"="*/*"
  "origin"="https://developer.microsoft.com"
  "sec-fetch-site"="cross-site"
  "sec-fetch-mode"="cors"
  "sec-fetch-dest"="empty"
  "referer"="https://developer.microsoft.com/"
  "accept-encoding"="gzip, deflate, br"
  "accept-language"="en-US,en;q=0.9,fr;q=0.8"
} `
-ContentType "application/json"

Right:

Invoke-WebRequest -Uri "https://graphexplorerapi.azurewebsites.net/openapi?url=/&style=geautocomplete&graphVersion=v1.0" `
-Headers @{
"method"="GET"
  "authority"="graphexplorerapi.azurewebsites.net"
  "scheme"="https"
  "path"="/openapi?url=/&style=geautocomplete&graphVersion=v1.0"
  "user-agent"="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
  "accept"="application/json"
  "origin"="https://developer.microsoft.com"
  "sec-fetch-site"="cross-site"
  "sec-fetch-mode"="cors"
  "sec-fetch-dest"="empty"
  "referer"="https://developer.microsoft.com/"
  "accept-encoding"="gzip, deflate, br"
  "accept-language"="en-US,en;q=0.9,fr;q=0.8"
} `

Notes

https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Simple_requests

Testing Instructions

Run GE, try the auto-complete feature.

@baywet
Copy link
Member Author

baywet commented Dec 14, 2020

CC @finsharp @bettirosengugi

@baywet
Copy link
Member Author

baywet commented Dec 14, 2020

CC @thewahome

@thewahome thewahome self-requested a review January 8, 2021 08:29
@thewahome thewahome merged commit 4ea148e into microsoftgraph:dev Jan 8, 2021
@baywet baywet deleted the patch-1 branch January 8, 2021 11:39
thewahome added a commit that referenced this pull request Jan 30, 2021
* Fix - replaces content-type header by accept to match HTTP and avoid CORS pre-flight (#783)

* Fix: modify permissions tab UI (#790)

* Track errors  (#777)

* Fix: sanitize url when fetching permissions (#794)

* Fix: remove wrongly placed working (#795)

* Fix: all permissions show as required (#797)

* Task: autocomplete hover styling (#801)

* Fix: Enable screen reader confirmation feedback (#802)

* Migrate to eslint (#627)

* Feature: resizable components (#766)

* Fix: add onItemInvoked action (#806)

* Fix: permissions consent (#807)

* Task: accessibility ci (#358)

* Fix: prevent resize when view expanded (#816)

* Feature: additional telemetry (#813)

* Fix: permissions tab UI (#815)

* Fix: shrink request section (#822)

Co-authored-by: jobala <[email protected]>
Co-authored-by: OfficeGlobal <[email protected]>
Co-authored-by: OfficeGlobal <[email protected]>
Co-authored-by: Azure Static Web Apps <[email protected]>
Co-authored-by: Elinor <[email protected]>
Co-authored-by: Millicent Achieng <[email protected]>
Co-authored-by: Sébastien Levert <[email protected]>
Co-authored-by: Ezrqn Kemboi <[email protected]>
Co-authored-by: Vincent Biret <[email protected]>
Co-authored-by: Joseph Ngugi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants