I'm stuck in a loop. I am using Pyramid > Nginx > AngularJS which is a great combo I've been using for years. However, I have come up against a problem trying to insert a temporary redirect based on the query string. Here's how the request is handled:
- The browser requests http://foo.com/bar
- Nginx detects the absence of a required query param and temporarily redirects to another domain (where the user fills in a survey)
- When the user submits the survey, they are sent back to Nginx, this time with the query param. eg http://foo.com/bar?foo=bar
- Nginx sees the required param and forwards the request to the Pyramid proxy
- Pyramid throws a HTTPNotFound error, which is what we want, and redirects using a 302 to http://foo.com/#/bar?foo=bar. This way, AngularJS will take over routing and stop sending requests to the server. ---- this is where the problem occurs. At this point, the user is being routed back to the survey because Nginx is ignoring everything after the hash and treating it like a fragment, of course. Unfortunately, that means that the query string is gone and Nginx applies the survey redirect again.
I have altering the Pyramid 302 by moving the hash and /bar segment to the right side of the query string. This does get the query string through Nginx properly, but then AngularJS doesn't interpret the hash anymore and doesn't apply the /bar route.
I hope that makes sense to somebody. Any clues would be appreciated.