WindmillWWindmill
Powered by
giyuG
Windmill•15mo ago•
12 replies
giyu

Support for HTTP Browser Redirects in Windmill Functions (302 Response Handling)

Hey guys,

I'm trying to implement URL redirects through a Windmill TypeScript function.

Specifically, I want to create an endpoint that, when accessed through a browser, redirects the user to another URL (in my test case, to Google.com).

Current behavior:

When I create a TypeScript function that returns redirect information like:

typescriptCopyexport async function main() {
return {
status: 302,
headers: {
'Location': 'https://www.google.com'
}
};
}

And access it via GET request (using the sync -> GET by path method), it returns the JSON response:

jsonCopy{"status": 302, "headers": {"Location": "https://www.google.com"}}
instead of actually redirecting the browser.

I've also tried:

- Returning HTML content with meta refresh or JavaScript redirect
- Using data:URL approach with base64 encoded HTML
- Setting different Content-Type headers

However, all attempts result in the JSON being displayed rather than the browser being redirected.

My question: Is it possible to configure Windmill functions to handle proper HTTP redirects (302 status codes) when accessed directly via browser, rather than just returning JSON? Or is there a recommended pattern for implementing URL redirects in Windmill?

This functionality would be particularly useful for implementing features like:

- Email click tracking with redirects
- OAuth callback handlers
- Short URL services

Any scenario where users need to be redirected through a Windmill endpoint

Technical goal: When a user clicks a link to my Windmill endpoint, their browser should automatically redirect to the destination URL, rather than displaying the JSON response.
WindmillJoin
3,362Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?
Recent Announcements
henri-c

Weekly kenote to tell you about our latest updates https://discord.com/channels/930051556043276338/1278977038430240813 https://youtube.com/live/2dGd9TdT8xs?feature=share

henri-c · 4d ago

Pyra

### HTTP tracing (EE) Capture HTTP requests made by job scripts as observability spans Features: - View HTTP request traces (method, URL, status, timing) in the job details UI - Auto-instrumentation for Native TypeScript, MITM proxy for other languages - Integrates with external OpenTelemetry collectors changelog: https://www.windmill.dev/changelog/http-tracing docs: https://www.windmill.dev/docs/advanced/instance_settings#http-tracing Additionally jobs memory metrics are now fully OSS!

Pyra · 2w ago

henri-c

First keynote of the year here https://discord.com/channels/930051556043276338/1278977038430240813 🙂

henri-c · 4w ago

Similar Threads

Error opening Windmill in a browser
AnyaAAnya / help
11mo ago
HTTP-Route wildcard support?
OestleOOestle / help
5mo ago
Automated Tests in Windmill
AlperAAlper / help
6mo ago
Getting Error in Windmill
AngadAAngad / help
3y ago