Firebase not adding CORS headers to REST requests
Is there a way to enable CORS for REST endpoints, as stated here and here? It looks like Firebase no longer adds them by default. It would be helpful for apps that don't need realtime connectivity or cant use websockets.
Here's a REST request to Firebase. If you check the response, there are no cors headers:
https://samplechat.firebaseio-demo.com/users/jack/name.json
firebase
add a comment |
Is there a way to enable CORS for REST endpoints, as stated here and here? It looks like Firebase no longer adds them by default. It would be helpful for apps that don't need realtime connectivity or cant use websockets.
Here's a REST request to Firebase. If you check the response, there are no cors headers:
https://samplechat.firebaseio-demo.com/users/jack/name.json
firebase
add a comment |
Is there a way to enable CORS for REST endpoints, as stated here and here? It looks like Firebase no longer adds them by default. It would be helpful for apps that don't need realtime connectivity or cant use websockets.
Here's a REST request to Firebase. If you check the response, there are no cors headers:
https://samplechat.firebaseio-demo.com/users/jack/name.json
firebase
Is there a way to enable CORS for REST endpoints, as stated here and here? It looks like Firebase no longer adds them by default. It would be helpful for apps that don't need realtime connectivity or cant use websockets.
Here's a REST request to Firebase. If you check the response, there are no cors headers:
https://samplechat.firebaseio-demo.com/users/jack/name.json
firebase
firebase
edited May 23 '17 at 12:09
Community♦
11
11
asked Dec 17 '15 at 17:36
Andy MillerAndy Miller
3841417
3841417
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Found the issue.
All the REST endpoints need to end in '.json', including put and post requests. That triggers Firebase to set the cross-origin headers to the origin on the request. By not adding the '.json' to the end of my POST request, the origin headers were not added so it looked like a CORS issue.
The example doesn't have a CORS header, so it looks like Firebase must add them only when needed.
Note that without.json
, Firebase tries to load the developer console available at<your-project>.firebaseio.com
.
– Rob DiMarco
Dec 17 '15 at 18:29
1
Out of curiosity, why are you using REST instead of the JS SDK?
– David East
Dec 17 '15 at 18:38
1
My app is primarily built for offline use, with only periodic syncs to the backend. I'd rather handle the offline state myself than set up websockets that constantly try to reconnect. I keep a parallel db in indexeddb where I keep track of offline modifications and then merge with online updates when the user goes back online.
– Andy Miller
Dec 17 '15 at 22:02
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f34340863%2ffirebase-not-adding-cors-headers-to-rest-requests%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Found the issue.
All the REST endpoints need to end in '.json', including put and post requests. That triggers Firebase to set the cross-origin headers to the origin on the request. By not adding the '.json' to the end of my POST request, the origin headers were not added so it looked like a CORS issue.
The example doesn't have a CORS header, so it looks like Firebase must add them only when needed.
Note that without.json
, Firebase tries to load the developer console available at<your-project>.firebaseio.com
.
– Rob DiMarco
Dec 17 '15 at 18:29
1
Out of curiosity, why are you using REST instead of the JS SDK?
– David East
Dec 17 '15 at 18:38
1
My app is primarily built for offline use, with only periodic syncs to the backend. I'd rather handle the offline state myself than set up websockets that constantly try to reconnect. I keep a parallel db in indexeddb where I keep track of offline modifications and then merge with online updates when the user goes back online.
– Andy Miller
Dec 17 '15 at 22:02
add a comment |
Found the issue.
All the REST endpoints need to end in '.json', including put and post requests. That triggers Firebase to set the cross-origin headers to the origin on the request. By not adding the '.json' to the end of my POST request, the origin headers were not added so it looked like a CORS issue.
The example doesn't have a CORS header, so it looks like Firebase must add them only when needed.
Note that without.json
, Firebase tries to load the developer console available at<your-project>.firebaseio.com
.
– Rob DiMarco
Dec 17 '15 at 18:29
1
Out of curiosity, why are you using REST instead of the JS SDK?
– David East
Dec 17 '15 at 18:38
1
My app is primarily built for offline use, with only periodic syncs to the backend. I'd rather handle the offline state myself than set up websockets that constantly try to reconnect. I keep a parallel db in indexeddb where I keep track of offline modifications and then merge with online updates when the user goes back online.
– Andy Miller
Dec 17 '15 at 22:02
add a comment |
Found the issue.
All the REST endpoints need to end in '.json', including put and post requests. That triggers Firebase to set the cross-origin headers to the origin on the request. By not adding the '.json' to the end of my POST request, the origin headers were not added so it looked like a CORS issue.
The example doesn't have a CORS header, so it looks like Firebase must add them only when needed.
Found the issue.
All the REST endpoints need to end in '.json', including put and post requests. That triggers Firebase to set the cross-origin headers to the origin on the request. By not adding the '.json' to the end of my POST request, the origin headers were not added so it looked like a CORS issue.
The example doesn't have a CORS header, so it looks like Firebase must add them only when needed.
answered Dec 17 '15 at 17:56
Andy MillerAndy Miller
3841417
3841417
Note that without.json
, Firebase tries to load the developer console available at<your-project>.firebaseio.com
.
– Rob DiMarco
Dec 17 '15 at 18:29
1
Out of curiosity, why are you using REST instead of the JS SDK?
– David East
Dec 17 '15 at 18:38
1
My app is primarily built for offline use, with only periodic syncs to the backend. I'd rather handle the offline state myself than set up websockets that constantly try to reconnect. I keep a parallel db in indexeddb where I keep track of offline modifications and then merge with online updates when the user goes back online.
– Andy Miller
Dec 17 '15 at 22:02
add a comment |
Note that without.json
, Firebase tries to load the developer console available at<your-project>.firebaseio.com
.
– Rob DiMarco
Dec 17 '15 at 18:29
1
Out of curiosity, why are you using REST instead of the JS SDK?
– David East
Dec 17 '15 at 18:38
1
My app is primarily built for offline use, with only periodic syncs to the backend. I'd rather handle the offline state myself than set up websockets that constantly try to reconnect. I keep a parallel db in indexeddb where I keep track of offline modifications and then merge with online updates when the user goes back online.
– Andy Miller
Dec 17 '15 at 22:02
Note that without
.json
, Firebase tries to load the developer console available at <your-project>.firebaseio.com
.– Rob DiMarco
Dec 17 '15 at 18:29
Note that without
.json
, Firebase tries to load the developer console available at <your-project>.firebaseio.com
.– Rob DiMarco
Dec 17 '15 at 18:29
1
1
Out of curiosity, why are you using REST instead of the JS SDK?
– David East
Dec 17 '15 at 18:38
Out of curiosity, why are you using REST instead of the JS SDK?
– David East
Dec 17 '15 at 18:38
1
1
My app is primarily built for offline use, with only periodic syncs to the backend. I'd rather handle the offline state myself than set up websockets that constantly try to reconnect. I keep a parallel db in indexeddb where I keep track of offline modifications and then merge with online updates when the user goes back online.
– Andy Miller
Dec 17 '15 at 22:02
My app is primarily built for offline use, with only periodic syncs to the backend. I'd rather handle the offline state myself than set up websockets that constantly try to reconnect. I keep a parallel db in indexeddb where I keep track of offline modifications and then merge with online updates when the user goes back online.
– Andy Miller
Dec 17 '15 at 22:02
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f34340863%2ffirebase-not-adding-cors-headers-to-rest-requests%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown