First of all, I server temporal ui under a sub path, following the directions here:
It works fine for the viewing part. But when I tried to terminate a workflow, the operation failed with a message:
“missing csrf token in request header” .
I’ve submitted an issue to ui-server project:
opened 08:32AM - 13 Dec 22 UTC
bug
### What are you really trying to do?
<!--
serve temporal ui under a sub pa… th
https://github.com/temporalio/ui-server/tree/main/docker#serve-ui-under-a-sub-path
-->
### Describe the bug
Error happens when we try to "Terminate" a workflow on the UI.
The error message is:
"missing csrf token in request header"
### Minimal Reproduction
1. build an image following the directions here: https://github.com/temporalio/ui-server/tree/main/docker#serve-ui-under-a-sub-path
2. start the temporal ui server
3. visit the ui page
4. select a running workflow, go to its details, click the "Terminate" button
5. the termination would fail with a message: "missing csrf token in request header".
### Environment/Versions
- OS and processor: [e.g. M1 Mac, x86 Windows, Linux]
- Temporal Version: [e.g. 1.14.0?] and/or SDK version
- Are you using Docker or Kubernetes or building Temporal from source?
### Additional context
But still I want to know if there is a quick workaround.
hi @whitecrow
Thank you, I am not able to reproduce this.
I have created the docker image docker build --build-arg TEMPORAL_PUBLIC_PATH=/custom-path -t temporal-ui-public-path .
And to run temporal with this UI I have changed the temporal-ui
from this docker compose
temporal-ui:
container_name: temporal-ui
depends_on:
- temporal
environment:
- TEMPORAL_ADDRESS=temporal:7233
- TEMPORAL_CORS_ORIGINS=http://localhost:3000
- TEMPORAL_PUBLIC_PATH=/custom-path
image: temporal-ui-public-path
networks:
- temporal-network
ports:
- 8080:8080
Terminating workflows from the UI works for me.
how are you starting the UI?
I see that there is an open issue in the UI repo related to terminating workflows, but the error message is different, do you think it could be related? An error occurred while terminating workflow · Issue #793 · temporalio/ui · GitHub
I deploy temporal server&ui on k8s, too.
Here are my deployment yaml config:
apiVersion: apps/v1
kind: Deployment
metadata:
name: temporal-web-deployment
spec:
replicas: 1
selector:
matchLabels:
app: temporal-web
template:
metadata:
labels:
app: temporal-web
spec:
containers:
- name: temporal-web
image: my-temporal-ui-image:2.8.x
env:
- name: LANG
value: "en_US.UTF-8"
- name: TEMPORAL_ADDRESS
value: temporal-server:7233
- name: TEMPORAL_CORS_ORIGINS
value: http://localhost:3000
- name: TEMPORAL_PUBLIC_PATH
value: /svc-temporal-web
ports:
- containerPort: 8080
resources:
requests:
cpu: 500m
@antonio.perez
Is there any relation to the ENV config TEMPORAL_CORS_ORIGINS?
I just found it worked fine if I visit my ui through localhost instead of a public IP .
1 Like
not sure about that. Let me ask internally!
Hi @whitecrow ,
You have to set TEMPORAL_CORS_ORIGINS to the same url that you will be terminating from. (I guess the public IP)
Let me know if it works.
@antonio.perez
I tried but it did not work.
The official image works fine with TEMPORAL_CORS_ORIGINS unchanged. So I think this problem is related to the subpath mechanism.
Solution 1: Add TEMPORAL_CSRF_COOKIE_INSECURE:True in your environment section in docker-compose file, it works for me.
Solution 2: try adding this line in your code before starting workflow execution:
await client.get_workflow_handle(WORKFLOW_ID).terminate()
cors:
cookieInsecure: true
Works for me.