Score:0

DO app hosting a site attempting to connect to a DO Droplet hosting an API results in an unhandled rejection

cc flag

It was suggested to post here from stackoverflow. Here's hoping.

There are two components to my application:

  • A DO 'App' which hosts a react website. This website makes requests to:
  • A DO 'Droplet' which hosts an API

When I attempt to connect from my development environment the Droplet, data is returned and the locally deployed react app displays the data.

However, when I deploy the react app onto the DO App and attempt to make the same request, I receive the error: Unhandled Rejection (TypeError): Not allowed to request resource. The browser console provides the following.

Not allowed to request resource
Fetch API cannot load http://xxx.xxx.xxx.xxx:8080/search/ due to access control checks
Unhandled Promise Rejection: TypeError: Not allowed to request resource.

I have attempted both the public IP for the Droplet hosting the API as well as the private IP. The same issue occurs once the application is deployed on the DO app.

Error

What areas can I look where there might be an issue?

const fetchReferences = async () => {

fetch(’http://xxx.xxx.xxx.xxx:8080/search/’, {. //this is the line that errors. 
method: ‘POST’,
body: JSON.stringify({
url: searchState.searchCriteria

On the python API I'm allowing everything through:

app = Flask(name)
CORS(app, resources={r"/“: {"origins”: “”}})
api = Api(app)
parser = reqparse.RequestParser()

Logging

Refgator API output log enter image description here

Refgator API error log

enter image description here

CORS issues?

So...

Why does an instance of the website loaded locally with yarn connect successfully to the droplet?

I suspect that this may be due to having shared keys with the Droplet hosting the API.

Why does an instance of the website loaded on the DO App platform connect without success to the droplet?

I have seen posts relating CORS issues between droplets and apps hosted on Digital Ocean. See here and here.

My knowledge on CORS is non-existent so confirming this is extremely time consuming.


It may be best to move the repo back to bitbucket and attempt to use a droplet rather than an app.

Michael Hampton avatar
cz flag
Did you look at why your Flask app is crashing? This doesn't look like a question for Server Fault (at least not yet). You still need to debug your code.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.