fsouza/fake-gcs-server

signedUrls are coming back as 404 b/c they appear to be missing some url segments

scottpatrickwright opened this issue · 2 comments

When I get a signed url back from fake gcs it seems to be missing the api version /v1, the bucket segment /b, & the object segment /o

This is what I get back from fake gcs when I ask for a signed url:

// I am seeing a 404 ❌
"http://127.0.0.1:4443/document-store-dev-1/1234567890.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=localdev%40dummy.com%2F20230911%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20230911T162353Z&X-Goog-Expires=900&X-Goog-SignedHeaders=content-type%3Bhost%3Bx-goog-meta-unique-key&X-Goog-Signature=29ec52bc116bcb8e7aa7597d5c30aa53fda618ce1009dd527735f192ff3c27bbc4182c24243ddb393e204d9358de6e3e2ceafc40b6fe1b2a6d5064c180481157a3880d6775adb2edb60cbe976041034880c62fd927221d6695b88ff8dc44e45be4ca36508db3a3edb01f752cb01fb4d5248a14a7823aa47727f3bd20b29f2a46"

This url has the missing segments manually added in:

// after I add the missing segment in this comes back as 200 👌
http://0.0.0.0:4443/storage/v1/b/document-store-dev-1/o/1234567890.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=localdev%40dummy.com%2F20230911%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20230911T161148Z&X-Goog-Expires=900&X-Goog-SignedHeaders=content-type%3Bhost%3Bx-goog-meta-unique-key&X-Goog-Signature=05957da39e4cfcd2d5bedd0b4c7692b22df777b7761938edddc0d374f86b7a5c3f483866a4f54fb6fc3d3507b29e5873e88568ff5983ea4be6078de8344eacaff360940fa161cadea9eba5ce03eb2296b73afd29529f87cf75a9596c51fa4c969ab29556ff07b9346be32d57e73b88d8ec357c097b3cbea464cb9495804dcdc9

I would expect that the signedUrl would be able to be hit normally.

(Thanks for the excellent package!)

fsouza commented

URL signing is client-only, I'm surprised that the behavior is different when using the emulator. Can you share a reproducer?

I had the same issue and solved it by passing -public-host localhost
https://github.com/fsouza/fake-gcs-server/blob/main/fakestorage/server.go#L318