302 response with location
Options
Riaan Backer
Member ✭
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?
Is it possible to return a 302 (redirect status) with a custom url to a browser that is connecting to the Xano api?
Comments
-
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 -
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. -
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 -
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!
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback