PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, September 8, 2022

[FIXED] Why is ExtJS sending an OPTIONS request to the same domain?

 September 08, 2022     ajax, extjs, http-options-method     No comments   

Issue

I'm loading my script on a domain and sending some data with POST and the use of Ext.Ajax.request() to that same domain.

Somehow the dev-tools show me, that there is a failed OPTIONS request.

Request URL : myurl-internal.com:8090/some/rest/api.php

Request Headers
  Access-Control-Request-Headers : origin, x-requested-with, content-type
  Access-Control-Request-Method  : POST
  Origin                         : http://myurl-internal.com:8090

It's both HTTP and not HTTPS. Same port, same host ... I don't know why it's doing this. The server can't handle such stuff and so the request fails and the whole system stops working.


Solution

It's not really specific to Ext JS -- see these related threads across other frameworks. It's the server properly enforcing the CORS standard:

for HTTP request methods that can cause side-effects on user data (in particular, for HTTP methods other than GET, or for POST usage with certain MIME types), the specification mandates that browsers “preflight” the request, soliciting supported methods from the server with an HTTP OPTIONS request header, and then, upon “approval” from the server, sending the actual request with the actual HTTP request method.

If you're going to use CORS, you need to be able to either properly handle or ignore these requests on the server. Ext JS itself doesn't care about the OPTIONS requests -- you'll receive the responses as expected, but unless you do something with them they'll just be ignored (assuming the server actually allows whatever you're trying to do).

If you are NOT intending to use CORS (which sounds like you aren't purposefully going cross-domain) then you need to figure out why the server thinks the originating domain is different (I'm not sure about that). You could also bypass CORS altogether by using JsonP (via Ext's JsonP proxy).



Answered By - Brian Moeskau
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing