Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] <fix CORS plz> #337

Closed
Robonau opened this issue Apr 12, 2022 · 8 comments
Closed

[Bug] <fix CORS plz> #337

Robonau opened this issue Apr 12, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@Robonau
Copy link
Contributor

Robonau commented Apr 12, 2022

What feature should be added to Tachidesk?

proper CORS headers

Why/Project's Benefit/Existing Problem

currently something along the lines of : nginx

    location /api {
      if ($request_method = 'OPTIONS') {
        add_header 'Access-Control-Allow-Origin' $http_origin always;
        add_header 'Access-Control-Allow-Credentials' 'true' always;
        add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS, PATCH, CONNECT' always;
        add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
        add_header 'Access-Control-Expose-Headers' 'Authorization' always;
        # Tell client that this pre-flight info is valid for 20 days
        add_header 'Access-Control-Max-Age' 1728000;
        add_header 'Content-Type' 'text/plain charset=UTF-8';
        add_header 'Content-Length' 0;
        return 204;
      }
      proxy_hide_header Access-Control-Allow-Origin;
      proxy_hide_header Access-Control-Allow-Credentials;
      proxy_hide_header Access-Control-Allow-Methods;
      proxy_hide_header Access-Control-Allow-Headers;
      proxy_hide_header Access-Control-Expose-Headers;
      add_header 'Access-Control-Allow-Origin' $http_origin always;
      add_header 'Access-Control-Allow-Credentials' 'true' always;
      add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS, PATCH, CONNECT' always;
      add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
      add_header 'Access-Control-Expose-Headers' 'Authorization' always;
      proxy_pass http://tachidesk:4567;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $http_connection;
    } 

is needed in order to allow connections from external sites (i want a ui on a different subdomain to the server)

@Robonau Robonau added the enhancement New feature or request label Apr 12, 2022
@Syer10
Copy link
Collaborator

Syer10 commented Apr 12, 2022

How is this different then what the server already does here? IE the config.enableCorsForAllOrigins()
https://github.com/Suwayomi/Tachidesk-Server/blob/db5c5ed5344416b1701db1d046861fe3776c5317/server/src/main/kotlin/suwayomi/tachidesk/server/JavalinSetup.kt#L45-L57

@Robonau
Copy link
Contributor Author

Robonau commented Apr 12, 2022

uhh, well that obviously doesn't work
given i had to do (what i showed in the op) to get it to do anything

@Syer10
Copy link
Collaborator

Syer10 commented Apr 12, 2022

It seems its working fine though?
6bOnIsx 1

@Robonau
Copy link
Contributor Author

Robonau commented Apr 12, 2022

Access to XMLHttpRequest at 'https://tachidesk.***/api/v1/manga/52/thumbnail' from origin 'https://sora.***' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

*** = my domain

@Syer10
Copy link
Collaborator

Syer10 commented Apr 12, 2022

I think this is a issue on your side, maybe your Ngix configuration or something. Its working fine on my docker server and a raw localhost server

@Robonau
Copy link
Contributor Author

Robonau commented Apr 12, 2022

im not the only one that has run in to this issue
https://discord.com/channels/801021177333940224/938069900914728980/963195904813309962

@Syer10
Copy link
Collaborator

Syer10 commented Apr 12, 2022

They were also using Nginx there. Nginx is probably trying to handle Cors itself instead of the server doing it (I think)

@Robonau Robonau closed this as completed Apr 12, 2022
@Robonau
Copy link
Contributor Author

Robonau commented Apr 12, 2022

nvm was more of a auth+cors bug than just cors

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants