(Translated by https://www.hiragana.jp/)
Force browser to do a preflight · Issue #16189 · mdn/content · GitHub
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

Force browser to do a preflight #16189

Closed
theking2 opened this issue May 18, 2022 · 3 comments
Closed

Force browser to do a preflight #16189

theking2 opened this issue May 18, 2022 · 3 comments
Labels
Content:Glossary Glossary entries help wanted If you know something about this topic, we would love your help!

Comments

@theking2
Copy link

MDN URL

https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request

What specific section or headline is this issue about?

Suggestions for implementation

What information was incorrect, unhelpful, or incomplete?

As pre-flight requests are created 'automatically" it makes is perhaps hard on the developer to implement a correct response to exactly such a request. How should a pre-flight request be debugged?

What did you expect to see?

Some suggestions how to coerce a browser to start a pre-flight request. Or a more elaborate process flow of request, pre-flight-request. and the expected responses.

Do you have any supporting links, references, or citations?

https://reflectoring.io/complete-guide-to-cors/

Do you have anything more you want to share?

Apart from that: excellent source

MDN metadata

Page report details
@github-actions github-actions bot added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label May 18, 2022
@sideshowbarker sideshowbarker added help wanted If you know something about this topic, we would love your help! Content:Glossary Glossary entries and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels May 19, 2022
@Josh-Cena
Copy link
Member

Josh-Cena commented Jun 23, 2024

@theking2 It has been a while but I don't think the request of this issue is clear. Are you asking for advice as the implementer of client code or server code? It seems you are implementing a server that responds to preflight requests, and you want to reliably trigger preflight requests in the browser so you can test your server's responses?

I believe most existing server solutions handle preflight requests automatically without explicitly handling OPTIONS requests. We already document what headers browsers expect from the preflight response.

@theking2
Copy link
Author

How to use devtools to force a pre-flight request in order to test an api implementation? That is what I'm looking for. Pre-Flight request results are cached and not performed anymore for some time (?) or until the browser closes (?).

@hamishwillee
Copy link
Collaborator

@theking2 Preflight requests are sent as options headers and as per the docs the server can set the cache time using Access-Control-Max-Age. Otherwise I would expect the default caching to be zero, but a quick internet search indicates it is 5 seconds on some browsers.

So the caching is up to the server you are talking to. If you don't have control over that server, then you can always select the "Disable Cache" checkbox in developer tools, which is usually in the Network tab.

I'm closing this as I consider the documentation sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:Glossary Glossary entries help wanted If you know something about this topic, we would love your help!
Projects
None yet
Development

No branches or pull requests

4 participants