dfinity / icx-proxy

A rust-based command line tool to serve as a gateway for a Internet Computer replica.
Apache License 2.0
28 stars 15 forks source link

400 error for assets with path /api/... #49

Open ninegua opened 2 years ago

ninegua commented 2 years ago

If some asset is uploaded to the asset canister under name api/xyz, then requesting it through icx-proxy will result in 400 error, which happens on both local dfx deployment and main net.

This is because icx-proxy hard coded path api to redirect to replica in these lines https://github.com/dfinity/icx-proxy/blob/4f732947846f3314e73db185e2932ad5a05c37b3/src/proxy/mod.rs#L157-L158

Given that /api is such a common prefix, shall we change it to something like /_/api ? Or at least give a better error message with some description of what could be going on?

Daniel-Bloom-dfinity commented 1 year ago

We will be deprecating and removing all these routes since the --proxy flag is now unused.

zire commented 1 year ago

Thanks Paul for identifying this issue for me. I had to change my api path from api/posts to api-ic/posts to avoid this awkward and very unexpected error. I thought it was something wrong with Svelte and it turned out to be good old IC ...

https://hbc6w-gqaaa-aaaag-aagdq-cai.raw.ic0.app/api-ic/posts

ilbertt commented 1 year ago

@Daniel-Bloom-dfinity when you said:

the --proxy flag is now unused.

what did you mean? Because I can still use the --proxy argument, and I get the log:

INFO icx-proxy: icx_proxy::proxy: Setting up `/_/` proxy to `<my-proxy-address>` version="0.10.1"

and I also see it's still handled in the code: https://github.com/dfinity/icx-proxy/blob/4f732947846f3314e73db185e2932ad5a05c37b3/src/proxy/mod.rs#L133-L134

What am I missing?