logdna / logdna-browser

A frontend browser logging and exception capturing library for LogDNA
MIT License
19 stars 14 forks source link

CORS is Not Recognizing URL after Whitelist is Updated #63

Closed donkeykong91 closed 1 year ago

donkeykong91 commented 1 year ago

Hello,

When I pass in the url parameter in the options object in the init function and then use the logger with logdna.debug('hello'), ~I get a CORS error to a mezmo url that I did not use.~ I get an error saying that I have not whitelisted the URL even though I already have (yesterday) in the Manage Organizations > CORS Origins page.

Edit: Regarding the mezmo URL, never mind. It seems, after waiting till the next day, it's now taking the URL I give it in the options object when I use the init function.

I'm currently using a logdna-based URL (I'm assuming it's the old way?). Exactly this: https://logs.us-south.logging.cloud.ibm.com/logs/ingest.

~But, in the error, I keep seeing it's trying to hit this URL:~

This is the URL that's trying to be hit with a POST call: https://logs.us-south.logging.cloud.ibm.com/logs/ingest?hostname=logdna-browser-logger&now=1671551408621&tags=LogDNA-Browser

This is how I use the init function:

logdna.init(ingestionKey, {
  url: 'https://logs.us-south.logging.cloud.ibm.com/logs/ingest'
});

logdna.debug('hello world');

Here are the errors I see in the console:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://logs.us-south.logging.cloud.ibm.com/logs/ingest?hostname=logdna-browser-logger&now=1671551408621&tags=LogDNA-Browser. (Reason: CORS request did not succeed). Status code: (null).

and

LogDNA Browser Logger is unable to send logs to LogDNA. Possible issues: - Your web apps url (https://localhost:4000/) is not listed in your LogDNA account's CORS whitelist domains - Ingestion key is incorrect - The configured LogDNA ingestion url is incorrect - LogDNA ingestion endpoint is down. https://status.mezmo.com/ Error: NetworkError when attempting to fetch resource.

I'm not sure if it's slow to update the CORS whitelist on IBM Cloud's side?

I would love some help on this!

Thank you!

donkeykong91 commented 1 year ago

Bump

svrakata commented 1 year ago

I am recieveing the logs but getting the same error in the console. This error LogDNA Browser Logger is unable to send logs to LogDNA. is due to sending too many request at once. After throttling the log function everywhing works as expected.

donkeykong91 commented 1 year ago

My problem was due to using the incorrect url. I updated the url to the correct one given to me by the LogDNA account and now it is working.

Thank you, also, @svrakata for the comment because I was also noticing that error on my end. I'll add a throttle for peace of mind.