Network error when attempting to fetch resource

819 views
Skip to first unread message

Nutchapol Dendumrongsup

unread,
May 11, 2020, 10:57:17 AM5/11/20
to Google App Engine
Hello fellow developers and data scientists. I have a question about a problem with accessing the API deployed on the google app engine from the javascript app deployed on Heroku. 

When I access my API link on google chrome, it works properly. However, when I use my javascript app deployed on Heroku to call my API link, it sometimes does not work and return me the network error. 

I have followed the instruction on "https://cloud.google.com/appengine/docs/standard/python3/config/appref" to enable the CORS access on my app API  in the app.ymal file on google app engine as the following  

runtime: python37instance_class: F4_1Ghandlers:
- url: /images
  static_dir: static/images
  http_headers:
    Access-Control-Allow-Origin: ‘*’

Similarly, I have also enabled the CORS access on my javascript app deployed on Heroku as shown in the picture attached. However, the problem still persists. I am not sure if it has to do with the way we set up our code or the google app engine server itself. If there is anything I could do besides what I have done I would love to hear that as well. Thanks a lot!
address_error.png
Screen Shot 2020-05-11 at 8.34.23 PM.png

Joshua Smith

unread,
May 11, 2020, 11:45:06 AM5/11/20
to Google App Engine
Look at the network activity debugger in your browser, or try hitting the URL using curl -v from the terminal.

That will generally help you sort out what headers are being included.

The rule you included would only add those headers to images, not your JSON stuff, but maybe that was just an example?

FWIW, I think it’s way more natural to do this in the python code:

      self.response.headers["Access-Control-Allow-Origin"] = "*"


--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/0a5daf81-3a94-4fe7-b5bb-0edfcb8a83f9%40googlegroups.com.
<address_error.png><Screen Shot 2020-05-11 at 8.34.23 PM.png>

Jafar Yousaf

unread,
Jul 12, 2020, 12:20:55 PM7/12/20
to Google App Engine
I got it clearly, your method of delivering a message is quite effective and comprehensive.


On Monday, May 11, 2020 at 8:45:06 PM UTC+5, Joshua Smith wrote:
Look at the network activity debugger in your browser, or try hitting the URL using curl -v from the terminal.

That will generally help you sort out what headers are being included.

The rule you included would only add those headers to images, not your JSON stuff, but maybe that was just an example?

FWIW, I think it’s way more natural to do this in the python code:

      self.response.headers["Access-Control-Allow-Origin"] = "*"


On May 11, 2020, at 10:03 AM, Nutchapol Dendumrongsup <nutcha...@gmail.com> wrote:

Hello fellow developers and data scientists. I have a question about a problem with accessing the API deployed on the google app engine from the javascript app deployed on Heroku. 

When I access my API link on google chrome, it works properly. However, when I use my javascript app deployed on Heroku to call my API link, it sometimes does not work and return me the network error. 

I have followed the instruction on "https://cloud.google.com/appengine/docs/standard/python3/config/appref" to enable the CORS access on my app API  in the app.ymal file on google app engine as the following  

runtime: python37instance_class: F4_1Ghandlers:
- url: /images
  static_dir: static/images
  http_headers:
    Access-Control-Allow-Origin: ‘*’

Similarly, I have also enabled the CORS access on my javascript app deployed on Heroku as shown in the picture attached. However, the problem still persists. I am not sure if it has to do with the way we set up our code or the google app engine server itself. If there is anything I could do besides what I have done I would love to hear that as well. Thanks a lot!

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-a...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages