CORS issue

433 views
Skip to first unread message

Tarun Surana

unread,
Nov 10, 2020, 7:32:40 AM11/10/20
to Angular and AngularJS discussion
Hello,
          I got in issue in cors policy.
Problem 1: CORS extension is enable in chrome browser so this website working correctly but if I disable CORS extension so get error in console window.
Access to XMLHttpRequest at 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Problem 2: How to enable CORS in AWS S3 bucket because I also getting error in AWS S3 bucket?
 Access to XMLHttpRequest at 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest' from origin 'http://cryptocurrency-app.s3-website.ap-south-1.amazonaws.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.  

I also shared a snapshot of CORS extension which is enable for handling CORS Issue.
Attachments area

Screenshot (257).png

Johannes Hillert

unread,
Nov 10, 2020, 5:54:34 PM11/10/20
to Angular and AngularJS discussion
Hey,

it is supposed to do that.

See:
Does the problem persist if you access 'https://pro-api...' from an origin with HTTPS scheme?

This describes how to serve the local app over HTTPS: Get angular-cli to ng serve over HTTPS

Settings this might also help: Access-Control-Allow-Origin

Kind regards,
Johannes

NANA DARKO

unread,
Nov 10, 2020, 11:43:35 PM11/10/20
to ang...@googlegroups.com
CORS error is not an issue with angular. You need to fix it on the api. Accept headers on the api. You should also allow calls from http localhost (whitelist). This can slightly vary depending on the language you're using for the api.
All the best.

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/c4c7de9b-1b70-4fe4-bc25-c47e9062043an%40googlegroups.com.

Tarun Surana

unread,
Nov 11, 2020, 7:18:39 AM11/11/20
to Angular and AngularJS discussion
can you suggest me what code should be write in angular for api?

NANA DARKO

unread,
Nov 11, 2020, 7:24:38 AM11/11/20
to ang...@googlegroups.com
Angular is not a backend framework. You should be using something like nodejs, python or c# for the backend/api. So depending on your programming language for the api then you find the fix indicated above.

Todd Zmijewski

unread,
Nov 11, 2020, 7:34:23 AM11/11/20
to ang...@googlegroups.com
I think the only way to access s3 documents semi-directly within a browser based http request is via cloud front. In cloud front the necessary headers can be added to response to allow cross origin requests.

phil.b...@gmail.com

unread,
Nov 12, 2020, 9:51:08 AM11/12/20
to Angular and AngularJS discussion
In response:
For a back-end API, I can recommend NestJS.  It's an MVC framework written for NodeJS in Typescript, that utilizes a lot of the conventions from Angular.  (I think it may be from the Angular team - but you can't quote me on that).
For the CORS issue - you will have to enable CORS on the S3 bucket: S3 - CORS

Tarun Surana

unread,
Nov 13, 2020, 7:18:44 AM11/13/20
to Angular and AngularJS discussion

Hello Google Group, I just want help to make range slider for filter data from table, I shared a snapshot of my code for imagine the solution.
Screenshot (264).png
Reply all
Reply to author
Forward
0 new messages