plutov / formulosity

Self-hosted Surveys as Code platform.
https://formulosity.vercel.app
MIT License
169 stars 20 forks source link

Error: Unable to call api #11

Closed ItsNoted closed 2 months ago

ItsNoted commented 2 months ago

Using the provided Docker Compose I am getting this error. It will show the main page of the survey but when I press start it gives this error.

image

plutov commented 2 months ago

This call is happening from the browser, so probably it's something related to NEXT_PUBLIC_CONSOLE_API_ADDR. Can you please confirm that you can get the list of surveys from http://localhost:9900/app/surveys?

The fact that this page loads means that API is up and working (server to server call), however something prevents running it from the browser. Do you have localhost pointing to 127.0.0.1 in your /etc/hosts?

ItsNoted commented 2 months ago

/app/surveys?

NEXT_PUBLIC_CONSOLE_API_ADDR is not in the compose I'm using because it was not in the one provided on the git clone.

I changed - UI_ADDR=http://localhost:3000 to http://ip.of.host:3000

/app/surveys gives output

{"code":200,"message":"","data":[{"uuid":"14789f0d-8374-48a2-9395-94823658a502","created_at":"2024-08-08T14:06:26.483016Z","parse_status":"success","delivery_status":"launched","error_log":"","name":"custom_theme","url_slug":"wt5zb4cqhkxk","url":"http://192.168.1.46:3000/survey/wt5zb4cqhkxk","config":{"title":"Survey Title","intro":"This is the introduction to the survey.\nIt can be multiple lines long.\n","outro":"Thank you for taking the survey.\nYour feedback is important to us.\n","theme":"custom","hash":"9e71f8a8dbebf390e0b8d07195afcad1371a76f1aef91986ee9aabfb4128dc08","questions":{"questions":[{"type":"single-choice","label":"What is the capital of Germany?","id":"question1","description":"","options":["Berlin","Munich","Hamburg","Cologne"],"uuid":""},{"type":"multiple-choice","label":"Which of the following are cities in Germany?","id":"18cbc44912e2567821ee0e411f82fe453348cc502e40aad4277d09da8cf48e39","description":"You can select multiple options","options":["Berlin","Munich","Paris","London","Hamburg","Cologne","Geneva","Oslo"],"uuid":"","validation":{"min":1,"max":3}},{"type":"short-text","label":"What is the capital of Germany?","id":"643f27ca573fc9ed6a8b67bbb29f0008bace7626d8e234ef51cfe12949911e52","description":"","uuid":""},{"type":"long-text","label":"What is the capital of Germany?","id":"5d6ce0582de006c61ce3a9c402f258b7985575fad070501fe34393e788c2f81f","description":"","uuid":""},{"type":"date","label":"When was the Berlin Wall built?","id":"4f75ce23cbd27b13018c4317f8a0b1e5e91eaa27a426b77d1e4a0deef7744c07","description":"","uuid":""},{"type":"rating","label":"How much do you like Berlin?","id":"7511f507e454ab8e2afd49338a3f784ebfe853cb42e35b9da28f0cd36a88e895","description":"","min":1,"max":5,"uuid":""},{"type":"ranking","label":"Rank the following cities by population","id":"236a1efc82bf873bf45b94807d59e739e54a15735dc77fb1ea3d62214deabde7","description":"","options":["Berlin","Munich","Hamburg","Cologne"],"uuid":""},{"type":"yes-no","label":"Is Berlin the capital of Germany?","id":"9001a156f3d843e98ddb01421a1688a510afcf91850d8b09ec56ae51ab6c9f05","description":"","uuid":""}]},"variables":{"variables":[{"id":"german-city-options","type":"list","options":["Berlin","Munich","Hamburg","Cologne"]}]},"security":{"duplicateProtection":"cookie"}},"stats":{"sessions_count_in_progress":0,"sessions_count_completed":0,"completion_rate":0}},{"uuid":"56b75216-d4a4-4b1f-b971-1088239b96e5","created_at":"2024-08-08T14:06:26.499709Z","parse_status":"success","delivery_status":"launched","error_log":"","name":"many_options","url_slug":"1gxcekeu4f13","url":"http://192.168.1.46:3000/survey/1gxcekeu4f13","config":{"title":"Short Title","intro":"Welcome to the survey.\n","outro":"Thank you for taking the survey.\n","theme":"default","hash":"3b36a46d49f17e1a5262704a5ac3235cd31ba0b194096524afe6eab8916671f2","questions":{"questions":[{"type":"single-choice","label":"What is the capital of Germany?","id":"1553e0d958a859b899a5ca5d86b71b0bd156f91c0727eabfc05f0fe54c3384a1","description":"Please select the correct answer.","options":["Berlin","Munich","Paris","London","Hamburg","Cologne","Geneva","Oslo","Rome","Madrid","Vienna","Warsaw","Prague","Budapest","Athens","Sofia","Bucharest","Moscow","Kiev","Minsk","Riga","Vilnius","Tallinn","Helsinki","Stockholm","Copenhagen","Amsterdam","Brussels","Luxembourg","Bern","Lisbon","Dublin","Reykjavik","Washington","Ottawa","Mexico City","Brasilia","Buenos Aires"],"uuid":""}]},"variables":null,"security":{"duplicateProtection":"cookie"}},"stats":{"sessions_count_in_progress":0,"sessions_count_completed":0,"completion_rate":0}},{"uuid":"1087c8a6-d820-4da3-99e1-8c286d4d1b65","created_at":"2024-08-08T14:06:26.502158Z","parse_status":"success","delivery_status":"launched","error_log":"","name":"short","url_slug":"obper5isho0r","url":"http://192.168.1.46:3000/survey/obper5isho0r","config":{"title":"Short Title","intro":"Welcome to the survey.\n","outro":"Thank you for taking the survey.\n","theme":"default","hash":"a9b4f9fda683b0b283cf365e0e77b80a35ffd81c9c0865779f6cb154d3c4d452","questions":{"questions":[{"type":"single-choice","label":"What is the capital of Germany?","id":"96bd240a5df0c17dc25d8242c9bdc0adf0c526e7e45f1ceb148285d6b5c9d259","description":"Please select the correct answer.","options":["Berlin","Munich","Paris","London","Hamburg","Cologne","Geneva","Oslo"],"uuid":""}]},"variables":null,"security":{"duplicateProtection":"cookie"}},"stats":{"sessions_count_in_progress":0,"sessions_count_completed":0,"completion_rate":0}},{"uuid":"a7392468-c3ba-42d5-9871-e812bf8cdc6d","created_at":"2024-08-08T14:06:26.503952Z","parse_status":"success","delivery_status":"launched","error_log":"","name":"simple","url_slug":"ysi8hdv40d71","url":"http://192.168.1.46:3000/survey/ysi8hdv40d71","config":{"title":"Survey Title","intro":"This is the introduction to the survey.\nIt can be multiple lines long.\n","outro":"Thank you for taking the survey.\nYour feedback is important to us.\n","theme":"default","hash":"c51d127f48556041eeb76c95c66cc59262ef671526e11985bfd286e99ed5f9e4","questions":{"questions":[{"type":"single-choice","label":"What is the capital of Germany?","id":"question1","description":"","options":["Berlin","Munich","Hamburg","Cologne"],"uuid":""},{"type":"multiple-choice","label":"Which of the following are cities in Germany?","id":"18cbc44912e2567821ee0e411f82fe453348cc502e40aad4277d09da8cf48e39","description":"You can select multiple options","options":["Berlin","Munich","Paris","London","Hamburg","Cologne","Geneva","Oslo"],"uuid":"","validation":{"min":1,"max":3}},{"type":"short-text","label":"What is the capital of Germany?","id":"643f27ca573fc9ed6a8b67bbb29f0008bace7626d8e234ef51cfe12949911e52","description":"","uuid":""},{"type":"long-text","label":"What is the capital of Germany?","id":"5d6ce0582de006c61ce3a9c402f258b7985575fad070501fe34393e788c2f81f","description":"","uuid":""},{"type":"date","label":"When was the Berlin Wall built?","id":"4f75ce23cbd27b13018c4317f8a0b1e5e91eaa27a426b77d1e4a0deef7744c07","description":"","uuid":""},{"type":"rating","label":"How much do you like Berlin?","id":"7511f507e454ab8e2afd49338a3f784ebfe853cb42e35b9da28f0cd36a88e895","description":"","min":1,"max":5,"uuid":""},{"type":"ranking","label":"Rank the following cities by population","id":"236a1efc82bf873bf45b94807d59e739e54a15735dc77fb1ea3d62214deabde7","description":"","options":["Berlin","Munich","Hamburg","Cologne"],"uuid":""},{"type":"yes-no","label":"Is Berlin the capital of Germany?","id":"9001a156f3d843e98ddb01421a1688a510afcf91850d8b09ec56ae51ab6c9f05","description":"","uuid":""}]},"variables":{"variables":[{"id":"german-city-options","type":"list","options":["Berlin","Munich","Hamburg","Cologne"]}]},"security":{"duplicateProtection":"cookie"}},"stats":{"sessions_count_in_progress":0,"sessions_count_completed":0,"completion_rate":0}}],"error_details":""}
plutov commented 2 months ago

Yes, it is in ui/.env.production file. I think it could also be related to CORS config. Let me remove it now as it's not needed for self-hosted app and you can try again.

plutov commented 2 months ago

Please try now without cors (pull/rebuild)

ItsNoted commented 2 months ago

Oh I see. Why not put all the env in the compose rather than some in the compose and some in an env file?

Anyway, I repulled and still having the same issue.

plutov commented 2 months ago

@ItsNoted can you please show the console error is there are any?

plutov commented 2 months ago

and good point on env vars, will try to keep them in one place.

plutov commented 2 months ago

Good news @ItsNoted I refactored env vars, improved cors, removed some redundant env vars. Now everything is in docker-compose. Can you please kindly give it a try one more time?