@@ -10,7 +10,7 @@ import * as Sentry from "@sentry/browser";
1010interface IConnection {
1111 headers : {
1212 "Content-Type" : string ;
13- "X-Parse-Application-Id" : string ;
13+ "X-Parse-Application-Id" ? : string ;
1414 "X-Parse-Session-Token" ?: string ;
1515 } ;
1616 url : string ;
@@ -41,26 +41,44 @@ const local: IConnection = {
4141} ;
4242
4343export function getConnection ( ) : IConnection {
44- if (
45- window . location . hostname === "bloomlibrary.org" ||
46- window . location . hostname === "next.bloomlibrary.org" ||
47- window . location . hostname === "embed.bloomlibrary.org" ||
48- window . location . hostname === "alpha.bloomlibrary.org"
49- ) {
50- return prod ;
51- }
44+ const result = prod ;
45+ // if (
46+ // window.location.hostname === "bloomlibrary.org" ||
47+ // window.location.hostname === "next.bloomlibrary.org" ||
48+ // window.location.hostname === "embed.bloomlibrary.org" ||
49+ // window.location.hostname === "alpha.bloomlibrary.org"
50+ // ) {
51+ // return prod;
52+ // }
5253
5354 if ( window . location . hostname . startsWith ( "dev" ) ) {
5455 return dev ;
5556 }
5657
57- if ( window . location . hostname === "localhost" ) {
58- return prod ;
59- //return dev;
60- // return local;
58+ // if (window.location.hostname === "localhost") {
59+ // return prod;
60+ // //return dev;
61+ // // return local;
62+ // }
63+
64+ // The browser will not allow us to provide this key here if we're running on
65+ // Bloom Reader, which intercepts web requests in order to enable zipping data
66+ // (and possibly eventually to do extra caching, provide local versions of
67+ // some reasources, etc.). However, it does not work with this mechanism
68+ // to provide the parse application id here. Not only does it not get through
69+ // to the parse server, even though BR attempts to pass on all headers,
70+ // but also, some "pre-flight" check fails, the WebView decides the request
71+ // is invalid, and it ignores the result. The only workaround I've found is
72+ // to have BR insert a marker into the user agent, and if this is found, we
73+ // suppress sending the parse application id. (The reader supplies it for the
74+ // real query to parse.)
75+ // Note: we'll probably have the same problem with X-Parse-Session-Token, if
76+ // we ever do anything embedded in BR that needs it.
77+ if ( window . navigator . userAgent . indexOf ( "sil-bloom" ) >= 0 ) {
78+ delete result . headers [ "X-Parse-Application-Id" ] ;
6179 }
6280
63- return prod ;
81+ return result ;
6482}
6583
6684// This should only be called when there is a current user logged in.
0 commit comments