I am developing the server side with Python (Flask) on Cloud run and the client side with Javascript (Vue.js) on Firebase. Python mainly reads and writes Firestore data. At this time, I encountered the following two issues.
This article describes these causes and countermeasures.
For 1, the OPTIONS request is called a preflight request, and if it's not a simple request, it seems to be a CORS request to see if the CORS protocol is understood. This can be eliminated by reviewing the request settings on the client side (in the REST API, there may be an Authentication header, so it may be skipped in many cases). For pre-flight requests, please refer to the following sites. After all, this wasn't a problem, so that's it.
--Cross-origin resource sharing (CORS): https://developer.mozilla.org/ja/docs/Web/HTTP/CORS )
This is due to the HTTP cache. ** When the response was generated on the server side, it was because I did not set the "Cache-control header" related to the HTTP cache **. As a result, the request did not originally go to the Cloud run side, and the HTTP cache in Firebase was responded to the client side. There is no problem with the first GET communication after deploying, but even if you change the contents of Firestore after that, the second and subsequent GET communication will be the same as the first content.
--HTTP cache: [https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching?hl=ja](https://developers.google.com/web/fundamentals/ performance / optimizing-content-efficiency / http-caching? hl = ja) --HTTP Cache (MDN web docs): https://developer.mozilla.org/ja/docs/Web/HTTP/Caching
Perhaps because it is too common sense of the web shop, there was not much article like that, so I wrote it as a memorandum.
Recommended Posts