asynchronous operation status links: add discoverable URLs in your proxy
An application proxy can make an asynchronous operation easier to discover by returning a status URL with its accepted response. That URL should identify your authorized application resource, not expose a credential or bypass your ownership checks. The design here belongs to your proxy: Genace’s current submission route returns a JSON job identifier and does not declare a Location header.
Create a local resource for the operation
Before submission, create an application operation associated with the signed-in user. After a successful upstream response, save the remote job_id on that record. Use the application’s operation ID to construct a local status URL. This lets the browser inspect progress without learning the server-side key or depending on internal upstream routing.
export function acceptedOperation(operationId) {
const statusPath = `/api/operations/${encodeURIComponent(operationId)}`;
return Response.json({
operation_id: operationId,
state: 'accepted',
status_url: statusPath,
}, {
status: 202,
headers: {
Location: statusPath,
'Cache-Control': 'no-store',
},
});
}
The remote identifier belongs in the preceding persistence operation, not in this small response builder. Call the builder only after storage succeeds, and never let a caller supply an arbitrary status path. Returning a local link is separate from storing the remote reference; neither step should be silently skipped.
Authorize every status read
When the browser follows the local URL, load the operation and compare its application owner with the current user. Then use the stored remote ID to GET the upstream job with the private server key. Genace checks its own account ownership, but a shared key does not distinguish users inside your application.
Return the fields your interface requires, such as rendering state, safe errors, and approved output references. Use an uncached response for private job status. Do not place bearer tokens, session identifiers, or signed reference image URLs in the Location value. URLs travel through browser history, logs, and monitoring systems.
Document the local contract precisely
Explain that your status URL represents an application operation and may include both generation and delivery phases. A rendered video can still be awaiting download or publication. Avoid naming all those phases as though they were Genace’s state enum.
If upstream submission returns a recoverable failure with error.job_id, save it on the same local operation and allow the status handler to expose reconciliation state. For a network exception without a job identifier, represent the outcome as uncertain rather than fabricating a remote status link.
Validate link construction and recovery
Test operation IDs containing characters requiring URL encoding. Ensure the link uses your intended origin or a safe relative path and cannot be redirected through a caller-supplied host header. Verify user A cannot follow user B’s status link successfully. Confirm refreshing the UI reuses the saved operation instead of resubmitting the prompt.
Also verify the response is sent only after the operation mapping is durable. A perfectly formed Location header cannot repair a lost database row. These checks make the link useful during recovery rather than merely decorative metadata.
See durable acceptance, tenant authorization, and resuming jobs.
Continue with code and integration
Where these facts come from
- Editorial keyword hypothesis; search volume not measured
- https://www.rfc-editor.org/rfc/rfc9110.html#name-location
- codebase: src/app/api/v1/video/generations/route.ts
- codebase: src/app/api/v1/jobs/[id]/route.ts