302 response with location

Options
Hi Team

Is it possible to return a 302 (redirect status) with a custom url to a browser that is connecting to the Xano api?

Comments

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    You can use the function Set HTTP Header (in Utility Functions).

    You can use this function twice: first to set the status and second to set the custom URL to say where to redirect to:
    HTTP/1.1 303 See Other
    Location: http://example.org/other
  • Riaan Backer
    Options
    Thanks  . Please confirm if I am on the right track here.

    [redirect.PNG]
    It throws an error (an unknown error has occurred) for all codes except a 200 OK, this might be as I might have done it wrong in the above example. I have also tried the set filter but I then get an error it expect a string and not an object.

    Also, on the response section, does it return the set headers by default or do you need to explicitly add them to the response section. The only option is to return system headers from the environment.
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    The internal Run & Debug isn't going to take you to navigate another webpage, which is why you are seeing an unknown error.

    You'll need to test this by entering the endpoint URL into your browser. Here's an example:

    https://www.loom.com/share/aff91750e2cb4d00a5b0c76c9295442c
  • Riaan Backer
    Options
    Great stuff, thanks for the prompt feedback! The only thing that made it confusing was the error in the UI and the fact that the debugger is throwing nothing. Its working!