[ 
https://issues.apache.org/jira/browse/OFBIZ-13231?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Nicolas Malin closed OFBIZ-13231.
---------------------------------
    Fix Version/s: 24.09.02
       Resolution: Fixed

> Ajax request fail on restful page
> ---------------------------------
>
>                 Key: OFBIZ-13231
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-13231
>             Project: OFBiz
>          Issue Type: Bug
>    Affects Versions: 24.09.01
>            Reporter: Nicolas Malin
>            Assignee: Nicolas Malin
>            Priority: Major
>              Labels: js, restful, uri
>             Fix For: 24.09.02
>
>         Attachments: image-2025-05-05-14-38-46-707.png
>
>
> I detected a problem 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
>  !image-2025-05-05-14-38-46-707.png! 
> *Reason :*
> SetTimeZoneFromBrowser is a request define in common-controller.xml, so 
> available on all component. In js the call is realize by :
> [code]
>             $.ajax({
>                 url: "SetTimeZoneFromBrowser",
>                 type: "POST",
>                 async: false,...
> [code]
> 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
> *How to fix :*
> we remove all relative js call and create a dedicate 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



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to