CORS cookie credentials from mobile WebView loaded locally with file://

前端 未结 6 2381
半阙折子戏
半阙折子戏 2020-11-29 03:24

Bear with me, this one needs a bit of explanation.

I am helping to build a hybrid mobile web app. The main codebase is HTML5 and JavaScript, which will be wrapped in

6条回答
  •  再見小時候
    2020-11-29 04:05

    My suggestion is set ACCESS-CONTROL-ALLOW-ORIGIN to null on server side

    Yes, This question bothers me for a little bit.

    Regarding to CORS spec, null can cater the situation where a CORS request from a file:// scheme

    And a pratical recommendation on that spec is to set it as origin-list-or-null, which is either a list of space-separated origins or simply "null" (by the way, the string %x6E %x75 %x6C %x6C from the definition for origin-list-or-null is literally null hex- encoded)

    Finally you will ask, wont that equal to * if we set ACCESS-CONTROL-ALLOW-ORIGIN to null since every request from scheme file:// is valid (which means every hybrid app can access your endpoint if it knows about your uri)?

    Well, given Access-Control-Allow-Credentials: true, I believe you've got a whole auth mechanism working on the server. It should have filtered those requests without the correct auth

    Hope it will help

提交回复
热议问题