jaydata icon indicating copy to clipboard operation
jaydata copied to clipboard

jaydata with odata provider: withCredentials has no effect

Open andriy-f opened this issue 8 years ago • 1 comments

Hi, I'm using JayData with OData provider. An I use code generated by jaysvcutil. I have noticed that option withCredentials is not propagated to underlying XMLHttpRequest when requesting data.

Code:

        import { factory } from '../services/JayDataContext'
        import { } from 'jaydata/odata'

        factory({
            oDataServiceHost: BACKEND_URL + "/odata",
            withCredentials: true
        })
            .onReady()
            .then(ctx => ctx.SomeEntity.toArray())
            .then(...

            })

The solution is to add change inside jaydata-odatajs (https://github.com/jaystack/olingo-odata4-js). file: net-browser.js change:

            if (request.headers) {
                for (name in request.headers) {
                    xhr.setRequestHeader(name, request.headers[name]);
                }
            }
            // Code below was added
            if(request.withCredentials) {
                xhr.withCredentials = true;
            }

andriy-f avatar Jul 18 '17 19:07 andriy-f

Nice, the fix (https://github.com/jaystack/olingo-odata4-js/commit/9d52ed6dbaa18a6bbcf6aac45a7b5a923a752688) has been merged already to https://github.com/jaystack/olingo-odata4-js. But npm doesn't have new version with this fix. If new version of jaydata-odatajs is published, then all that wold be needed to fix this issue is to update dependency on jaydata-odatajs in projects jaydata and jaydata-dynamic-metadata

andriy-f avatar Jul 25 '17 15:07 andriy-f