Hi! I’m trying to send a POST from my Angular app to the Digital Ocean API, using the following endpoint:
https://cloud.digitalocean.com/v1/oauth/token?client_id=MY_CLIENT_ID&client_secret=MY_CLIENT_SECRET&code=MY_CODE’&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 https://apitester.com/, I get the response successfully.
Any idea? Thanks!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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,
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.