-
Notifications
You must be signed in to change notification settings - Fork 571
Fixed: Ajax request fail on restful page (OFBIZ-13231) #889
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
base: trunk
Are you sure you want to change the base?
Conversation
A problem was detected with some ajax call did by js script that failed with error 405 like : https://demo-next.ofbiz.apache.org/webtools/control/entity/find/SetTimeZoneFromBrowser Reason : SetTimeZoneFromBrowser is a request define in common-controller.xml, so available on all component. In js the call is realized by : $.ajax({ url: "SetTimeZoneFromBrowser", type: "POST", async: false,... So the navigator use the relative url to execute the call. In general case we have a page like https://demo-next.ofbiz.apache.org/$component/control/$request so js script realized their call with https://demo-next.ofbiz.apache.org/$component/control/$request-js. Like each request-js are present on common-controller.xml all component that include it can response. With rest url, the uri pattern is more complex and the script js that generate a relative call like we have upper : _https://demo-next.ofbiz.apache.org/webtools/control/entity/find/SetTimeZoneFromBrowse_. The ControlServlet behind failed to retrieve the correct request and generate a http error 405 To fix : we remove all relative js call and create a dedicated webapp for that. [code] $.ajax({ url: "/common-js/control/SetTimeZoneFromBrowser", type: "POST", async: false,... [code] To pass through the authentification (we implement a new webapp), we store a jwt token with the current userLogin after the authentification that will use by common-ext to confirm authentification. This cookie is available during all the session time
|
framework/security/src/main/java/org/apache/ofbiz/security/SecurityUtil.java
Dismissed
Show dismissed
Hide dismissed
Hi @nmalin, I tried to get a 405 using https://demo-next.ofbiz.apache.org/webtools/control/entity/find/SetTimeZoneFromBrowser to no avail, what could I miss? |
Hi Nicolas, Forget it, that was on Win7 with Edge. I see a 405 on Ubuntu 20.04 with last FF. |
Hi Jacques, What is the return code on edge ? Because the url https://demo-next.ofbiz.apache.org/webtools/control/entity/find/SetTimeZoneFromBrowse can't be delivery correctly by ofbiz |
It's all 200 but a 404 for messages_en.js that is not a real issue, messages_en.js is the default. Note that it's not only Edge but more probably due to Win7. Anyway I applied the PR.patch on Ubuntu and the 405 disappeared. I did not review all but I can at least confirm that running |
and https://localhost:8443/webtools/control/entity/find/SetTimeZoneFromBrowser response as json or it's catch by the rest pattern and return a html page ? |
Not sure about being caught by REST, but an HTML page is returned with a 401 More clear maybe:
|
Looks like the call to the login view is due to REST, right? |
right :) your call failed to 401 because the url is catch by This call don't match the controller entry ` on common-controller.xml |
Great, sounds OK with me, thanks Nico |
Tks to look on it. I propose to commit this on trunk and also in 24.09, if you have a look to confirm my choice |
A problem was detected with some ajax call did by js script that failed with error 405 like : https://demo-next.ofbiz.apache.org/webtools/control/entity/find/SetTimeZoneFromBrowser
Reason :
SetTimeZoneFromBrowser is a request define in common-controller.xml, so available on all component. In js the call is realized by :
So the navigator use the relative url to execute the call. In general case we have a page like https://demo-next.ofbiz.apache.org/$component/control/$request so js script realized their call with https://demo-next.ofbiz.apache.org/$component/control/$request-js. Like each request-js are present on common-controller.xml all component that include it can response.
With rest url, the uri pattern is more complex and the script js that generate a relative call like we have upper : https://demo-next.ofbiz.apache.org/webtools/control/entity/find/SetTimeZoneFromBrowse. The ControlServlet behind failed to retrieve the correct request and generate a http error 405
To fix :
we remove all relative js call and create a dedicated webapp for that.
To pass through the authentification (we implement a new webapp), we store a jwt token with the current userLogin after the authentification that will use by common-ext to confirm authentification. This cookie is available during all the session time