I’ve encountered a problem with Netlify Proxy when Origin Server returns a 303 See Other response code.
In short: When I execute a query containing a query string, it is added to the Location header returned from the origin server and sent to the client modified.
I think, Netlify should reconsider if it is expected. At the moment, netlify-cli seems to be doing the right thing i.e. pass through query parameters from client request to the origin server.
Netlify Proxy pass through query parameters from client request to the origin server and additionally append query parameters from client request to origin response Location header.
At the moment, if Origin server returns 3xx Location with any query param, all other from client request will be stripped. If it is expected behaviour, I think it should be documented somewhere.
You are right, but at the moment, we are not talking about 3xx redirects at Netlify CDN level (post you cited is about that). We are talking about redirects made at Origin Server level (status=200 in _redirects, not 3xx). For 3xx redirects netlify-cli and Edge Servers work the same way: all request params are appended to response Location if in the redirect to is not specifying any query param.
At the moment, there is no possible, to return 3xx redirect issued by Origin Server without empty query params if client request contains them. There are only two options: return all request query params or add any dummy query param within Origin response to obscure requests ones.
For me, this scenarion makes a lot of sense in case of redirects on the CDN level, but not necessarily when the redirection logic (as much as we want, including rewriting all parameters to the response) is handled by the Origin server.
If you disagree, I think this topic can be closed, but I won’t be very happy about it
We disregard the “preserved” params if the destination sends any query param in a response. So, it’s not about status_code being the only one that’s dropped, we’re dropping url too, but since the other server is sending the url param, you’re seeing that. To verify, you can try visiting:
Now you’ll see url2 as the query param on the final URL.
Regarding the guide talking about 3xx, I think you misunderstood/misread. There was one key line:
So we were always doing this for the 200 rewrite, which you’re using. Based on that guide, we just started doing it for 3xx as well.
The change, if made now could break the workflows of various websites that might be relying on this behaviour. The ideal way, I believe would be to add a configuration option. If that sounds okay to you, I can add that as a feature request. If you feel differently, let us know.
IMHO, there will be more sense for passthrough query param only from Netlify proxy to the origin. That is my understanding of “preserving params”. There is no option to check this behaviour before 301/302 update, but I think actual behaviour may be side-effect of this update.
If you think, you may add the feature request for optional disabling query params passthrough for 3xx responses returned by origin server (200 redirect rule). For some use cases it may be vital.
Netlify does attempt to preserve the query parameters that were passed. This is applicable to all 3xx redirects. For instance, if you have a redirect rule with a 301 or 302 HTTP status, Netlify will automatically pass on all query string parameters to the destination paths. However, you can also choose to define a redirect path based on a specific parameter or combination of parameters.
This is applicable to all 3xx redirects. For instance, if you have a redirect rule with a 301 or 302 HTTP status, Netlify will automatically pass on all query string parameters to the destination paths.
Yes, you are right, but we are talking about 200 redirect rule. Current behavior does not allow to ‘consume’ query string by origin server. In other words, it is not possible to return redirect Location without any query string.