Closed jjalan closed 4 years ago
Hi @jjalan, thanks for reaching out
In the context of an Electron app, one option would be to exclude the Origin
header for the logdna.com domain. You can do this with the onBeforeRequest
method:
https://www.electronjs.org/docs/api/web-request#webrequestonbeforerequestfilter-listener
With the origin set to null
we will not check for whitelisted domain(s) to apply CORS headers for in the response. This is likely what you want, as there is no "domain" in this context to restrict logging calls to.
@mdeltito,
Thanks. That works. For future reference, here is full snippet to include in Electron app:
app.on("ready", () => {
// Set Origin header to null for all requests out to LogDNA
// otherwise the request fails due to CORS issue
session.defaultSession.webRequest.onBeforeSendHeaders({
urls: ['https://*.logdna.com/*']
}, (details, callback) => {
details.requestHeaders['Origin'] = null;
callback({ requestHeaders: details.requestHeaders })
});
});
Excellent, we're glad the suggestion worked. While you're at it, we just released a new version of the node client that you should try out. Thank you, and let us know if we can help in the future.
Hello,
I have an electron app that is bundle with React application. I am trying to use logDNA from inside React views on Electron.
It works fine during development as Electron serves the react application via a local dev server as long as I have
http://localhost
in the whitelisted domain in the settings on LogDNA.However, electron app simply serves the React index.html via
file://
in production build. These logs are not showing up in LogDNA. See the error trace from network tab:I tried to add
file://
as whitelisted domain from LogDNA but it won't let me.Error (from network tab):
Invalid value for domain: file://
Any pointers in this regard would be greatly appreciated.