jaystack/jaydata

jaydata with odata provider: withCredentials has no effect

andriy-f opened this issue · 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;
            }

Nice, the fix (jaystack/olingo-odata4-js@9d52ed6) 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