CONSOLE ERRORS
See original GitHub issueI’m using contentful with the latest Angular version 10.0.5 and I have errors in the dev console.
environment.ts
...
contentful: {
space: 'MY_SPACE',
accessToken: 'MY_TOKEN',
}
contentful.service.ts
@Injectable({
providedIn: 'root'
})
export class ContentfulService {
private cdaClient = createClient(environment.contentful);
constructor(private localStorageService: LocalStorageService) {
}
private getNewsList(query?: ContentfulQuery): Promise<Entry<ContNewsFieldItem>[]> {
return this.cdaClient.getEntries<ContNewsFieldItem>(Object.assign({
content_type: 'SOME_CONTENT_TYPE'
}, query))
.then((res: EntryCollection<ContNewsFieldItem>) => res.items);
}
...
Each time when I call contentfulService.getNewsList({limit: 6})
I get a list of news but in the dev console I see 2 errors:
xhr.js:126 Refused to set unsafe header "user-agent"
xhr.js:126 Refused to set unsafe header "Accept-Encoding"
How can I fix it or it’s your bug?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:10 (1 by maintainers)
Top Results From Across the Web
How to open the browser console to view errors
How to open the browser console to view errors ; Browser Console · : - Ctrl + Shift + J (Windows/Linux) - Command...
Read more >Fix JavaScript errors that are reported in the Console
Open the demo webpage JavaScript error reported in the Console tool in a new window or tab. · Right-click anywhere in the webpage...
Read more >JavaScript console.error() Method - W3Schools
The error() method writes an error message to the console. The console is useful for testing purposes. Syntax. console.error(message). Parameters ...
Read more >Debugging Browser Console Errors - Delicious Brains
Open the Chrome developer tools (F12 / ⌘-Option-I) · Click the Console tab · Click the Clear console icon to clear the current...
Read more >Browser errors were logged to the console - Chrome Developers
# How the Lighthouse browser error audit fails. Lighthouse flags all browser errors logged to the console: Lighthouse audit showing browser ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Experiencing the same issue with v9.1.12. I dug into the stack trace and found out that the reason I’m getting this message is because of Contentful’s
isNode
function:When this function evaluates to
true
, theuser-agent
andAccept-Enconding
headers are set.Normally, this shouldn’t be a problem, however in edge cases you might have your client side JS polyfilled to use node-only packages. For my case, it’s because we’re using
aws-amplify
which unfortunately requires node packages. If using a bundler like Vite which doesn’t automatically polyfill these things, you have to add theprocess
global variable into your code, for instance with something like:The issue was solved on my end by adding the
browser: true
line, since theisNode
function looks for it in order to decide if it’s running in a browser or node.Hopefully this helps someone, and perhaps it’s a good thing to put into the docs for cases where you’re using polyfilled client side code.
Updating contentful to latest version didn’t help. Also seeing these errors.