dunglas / vulcain

Fast and idiomatic client-driven REST APIs.

Home Page:https://vulcain.rocks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Response's body is percent encoded when parametrized queries

Nayte91 opened this issue · comments

Hello,

When I fetch a resource with a "fields" query parameter, the received fields are percent encoded. But when I vanilla fetch or header-based-fields fetch, the resource's fields are "normal".

Front
scenario A
What I code:

const eventResp = await fetch("https://localhost:8000/events/2?fields=\"\/subtitle\",\"name\"")
console.log(await eventResp.json())

What it outputs:

Object { subtitle: "Internationaux%20de%20France%20de%20tennis%202019", name: "Roland%20Garros%202019" }

ScenarioB
What I code:

const eventResp = await fetch("https://localhost:8000/events/2")
console.log(await eventResp.json())

What it outputs:

Object { "@context": "/contexts/Event", "@id": "/events/2", "@type": "https://schema.org/Event", id: 2, name: "Roland Garros 2019", subtitle: "Internationaux de France de tennis 2019", heading: "120ème édition des Internationaux de France de tennis sont le plus grand tournoi de la saison de tennis sur terre battue.", startDate: "2019-05-26T00:00:00+00:00", endDate: "2019-06-09T00:00:00+00:00", visibility: "public", … }

Back
PHP 6.1 / APIP 3.0.3, served by Caddy 2.7.4 / http.handlers.vulcain v0.5.0

localhost:8000

log

route {
    root * /app/public
    vulcain
    push
    php_fastcgi backend:9000
    encode zstd gzip
    file_server
}

Another proof/test with Postman (see screenshot here)

  1. Is it intended?
  2. What can I do to avoid this behavior?
  3. Do you need more information from my context?

Thank you!

New try with updated stack:
API-Platform 3.2.* / PHP8.2
dunglas/vulcain:latest

nayte@fresh:~/Ephemere-back$ docker compose exec webserver caddy version
Vulcain.rocks 1.0.0 Caddy v2.7.5 h1:xxxxxxxxx...

Caddyfile

localhost:8000 {
    log

    route {
        root * /app/public
        vulcain
        push
        php_fastcgi backend:9000
        encode gzip
        file_server
    }
}

Same "issue"!

image

The test is done locally, as soon as I can update my prod (see #127), the tests will be possible.