Problem with CORS on Digital Ocean API

  • Posted January 31, 2019
  • API

Hi! I’m trying to send a POST from my Angular app to the Digital Ocean API, using the following endpoint:’&grant_type=authorization_code&redirect_uri=MY_APP_URL

On Chrome delevoper tools I can see an OPTIONS request is sent first, and returned with 404, so the POST is never sent. When I try the same endpoint on, I get the response successfully.

Any idea? Thanks!


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

If your network request is failed. due to the CORS issue, then you should use node module CORS and configure the CORS object on the server.

The way CORS works is that if it gets the request from an unknown host or domain, then it will give you an error saying that cross-site origin request: access denied.

Which means that you are unknown to the server or, in this case, malicious actor.

It is the security feature of browsers.

If you are working with Authentication in Angular 10 app, then you have to send a post request to the server, and then if all the data is valid, it will store the user credentials to the database.

When a user tries to login for the first time, the server will return a jwt token, and that token will be saved on the clientside.

Every time the user to try to access the server resource, it will check for the token, and if it finds, it sends the proper response; otherwise, it will throw the error.

In your case, maybe DigitalOcean API can not verify the token, or you have not configured the CORS object on the backend language.

Configure the CORS object and whitelist your domain and try again.

I hope this helps,

Best Regards,