CORS error when self-hosting using docker
Issue Description
When self-hosting puter, after entering the username and password for the default_user, the screen stays blank henceforth and nothing happens even on reload. When looking at the console, there are CORS errors.
Steps to Reproduce
In my setup, I am using Hashicorp Nomad (and other components such as HCP Consul, HCP Vault and Traefik) to deploy a job for Puter. This is irrelevant however, since I believe that by using the docker-compose.yml file in the project root with an NGinx reverse proxy in front (maybe installed on the host machine), the same issue would be obtained.
Expected & Actual Behavior No CORS errors are obtained and requests/responses are sent/received correctly between the client and the API. I wouldn't expect this to be something hard to solve, maybe it's just adding an NPM module or a little block of code on the API side for domains that should be whitelisted or something in order to avoid CORS errors.
Addition Information or Screenshots (if applicable)
My /etc/config.json file; maybe there's just something I didn't set or wrongfully set:
{
"config_name": "generated default config",
"env": "dev",
"nginx_mode": true,
"server_id": "api.puter.konnect.dev",
"http_port": "443",
"domain": "puter.konnect.dev",
"protocol": "https",
"contact_email": "[email protected]",
"services": {
"database": {
"engine": "sqlite",
"path": "puter-database.sqlite"
},
"thumbnails": {
"engine": "purejs"
},
"file-cache": {
"disk_limit": 16384,
"disk_max_size": 16384,
"precache_size": 16384,
"path": "./file-cache"
}
},
"cookie_name": "redacted",
"jwt_secret": "redacted",
"url_signature_secret": "redacted",
"pub_port": "443"
}
FYI, I did try setting http_port and pub_port to 80 as well, and I get the same issue. puter.konnect.dev and api.puter.konnect.dev both also point to the same docker container. I am also using the latest docker image provided.
Tooling
- [ ] Development (
npm run start) - [ ] Docker (via
docker run) - [x] Docker (via
docker-compose)
Puter version (if accessible)
Click the profile button on the top-right, then "Settings". The version number will be printed at the bottom
this might be related to #230 where my main domain is a subdomain itself.
I also saw that this commit was made. Are those changes present in the latest docker image?
this might be related to #230 where my main domain is a subdomain itself.
I also saw that this commit was made. Are those changes present in the latest docker image?
Yes that commit should fix the issue. Which docker image are you using?
Indeed, but it doesn't fix the issue unfortunately :(
I am using this docker image:
https://github.com/HeyPuter/puter/pkgs/container/puter/200646846?tag=sha-ea61799
I tried building the docker image on my own as well and ran it, but still the same issue.
You're accessing via konnect.dev as your URL in the browser too, right? I'm kind of at a loss, I'm not sure why this wouldn't be working. How does it work when you do local dev instructions? (although I realize that might not be helpful/relevant to your deployment)
Hey @KernelDeimos, thanks for your help on this. I don't know if I did something wrong or not, but it randomly started working I guess? Don't know if it was related to my config, but it does work. Sharing my config again below for anyone else who might stumble across this in the future. Oh and BTW, there are several errors popping up in the console when env is set to prod but that might already be something you guys are looking into. Great work on this project and I can't wait to see how it evolves in the future!
{
"config_name": "generated default config",
"env": "dev",
"nginx_mode": true,
"server_id": "api.puter.konnect.dev",
"http_port": "443",
"domain": "puter.konnect.dev",
"protocol": "https",
"contact_email": "[email protected]",
"services": {
"database": {
"engine": "sqlite",
"path": "puter-database.sqlite"
},
"thumbnails": {
"engine": "purejs"
},
"file-cache": {
"disk_limit": 16384,
"disk_max_size": 16384,
"precache_size": 16384,
"path": "./file-cache"
}
},
"cookie_name": "REDACTED",
"jwt_secret": "REDACTED",
"url_signature_secret": "REDACTED",
"pub_port": "443"
}