0

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:

  1. The browser requests http://foo.com/bar
  2. Nginx detects the absence of a required query param and temporarily redirects to another domain (where the user fills in a survey)
  3. 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
  4. Nginx sees the required param and forwards the request to the Pyramid proxy
  5. 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.

1 Answer 1

1

The fragment is never sent to the server, therefore you can not create a location in nginx to react on it.

If redirect/forward to Pyramid happens only if there is 'bar', then you can do this:

location = / {
  # deliver your angular app
}

location /bar {
   # redirect or forward to Pyramid
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.