Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Unable to update product packaging from hunger game #7796

Closed
alexfauquette opened this issue Dec 4, 2022 · 5 comments · Fixed by #7781
Closed

[Bug] Unable to update product packaging from hunger game #7796

alexfauquette opened this issue Dec 4, 2022 · 5 comments · Fixed by #7781
Assignees
Labels
API v3 🐛 bug This is a bug, not a feature request. CORS ✏️ Editing 🎯 P1 📦 Packaging https://wiki.openfoodfacts.org/Category:Recycling

Comments

@alexfauquette
Copy link
Member

alexfauquette commented Dec 4, 2022

What

  • Unable to update product packaging from hunger game
  • Sounds like there is a CORS problem:

I tried to use experimental hunger game page to update a product packaging (this product) but it returns CORS issue and the product page is not updated

I reproduced the same request by copy-pasting url/body in postman, and then, it update product information, cf following the modification line:

4 décembre 2022 à 13:32:54 CET - openfoodfacts-contributors - API v3 - voir

Here is the request used:

https://world.openfoodfacts.org/api/v3/product/8001420000788

{
    "product": {
        "fields": "updated",
        "packagings": [
            {
                "shape": {
                    "id": "en:bag"
                },
                "material": {
                    "id": "en:plastic"
                },
                "recycling": {
                    "id": "en:recycle-with-plastics"
                }
            }
        ]
    }
}

like

To Reproduce

  • Go to the hunger game page
  • click on button to see the product in another page
  • fill the table
  • open network debug
  • send annnotation

You should see a PATCH request sent returning CORS issue and the product is not updated

Type of device

REST-API

@alexfauquette alexfauquette added the 🐛 bug This is a bug, not a feature request. label Dec 4, 2022
@teolemon teolemon added ✏️ Editing 📦 Packaging https://wiki.openfoodfacts.org/Category:Recycling API v3 🎯 P1 labels Dec 5, 2022
@stephanegigandet
Copy link
Contributor

@alexfauquette The OPTIONS request is sent those headers:

access-control-allow-credentials: true
access-control-allow-origin: https://hunger.openfoodfacts.org

I'm not sure which one it wants though. Maybe access-control-allow-methods? Anything else?

@alexfauquette
Copy link
Member Author

Yes, Access-Control-Allow-Methods could be the source of the problem.

I was not aware about that but only GET, HEAD, and POST are considered as simple requests. Others have a preflight request and if the server does not allow the method, the browser will nether send the request.

@teolemon teolemon added the CORS label Dec 12, 2022
@teolemon
Copy link
Member

@stephanegigandet any update

@alexgarel
Copy link
Member

I will look into this.

@alexgarel alexgarel self-assigned this Dec 19, 2022
@teolemon
Copy link
Member

Thanks @alexgarel

This was referenced Dec 23, 2022
alexgarel added a commit that referenced this issue Jan 6, 2023
* centralize cors headers handling in perl code
* add Access-Control-Allow-Methods correctly
* add tests

* cleaned nginx prod configurations
* make docker nginx more close to production configuration

should fix:
- #7796
- #7901
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API v3 🐛 bug This is a bug, not a feature request. CORS ✏️ Editing 🎯 P1 📦 Packaging https://wiki.openfoodfacts.org/Category:Recycling
Projects
Status: 🏗 In progress
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants