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

CORS Issue with Web Client #19

Closed
alex-phillips opened this issue Dec 1, 2019 · 9 comments
Closed

CORS Issue with Web Client #19

alex-phillips opened this issue Dec 1, 2019 · 9 comments
Labels

Comments

@alex-phillips
Copy link

I wrote a subsonic-compatible web UI which works great with Airsonic. I'm sure it would also work with gonic, but it looks like I'm getting some CORS issues in the browser.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://gonic.mydomain.com/rest/getAlbum.view?f=json&c=qooxtun…15&u=USERNAME&s=I79q1o&t=TOKEN&id=56. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

Would something like this be an easy fix? It looks like all of the errors in my console are for the getAlbum.view endpoint?

@sentriz
Copy link
Owner

sentriz commented Dec 1, 2019

can you try a curl --head "https://gonic.yourdomain.com/rest/getAlbum.view" there should be cors headers in the response.

I think it's set up right because gonic works with jamstash which probably does cors stuff (but maybe not?)

@alex-phillips
Copy link
Author

Hmm, it does. Not sure what the issue is then. Here's the response from my gonic server vs my airsonic server:

Airsonic:

curl --head "https://airsonic.mydomain.com/rest/getAlbum.view?f=json&c=qooxtunes&v=1.15&u=USERNAME&s=OaUSpg&t=TOKEN&id=2"
HTTP/1.1 200 
Server: nginx/1.16.1
Date: Sun, 01 Dec 2019 16:58:41 GMT
Content-Type: application/json;charset=UTF-8
Content-Length: 7653
Connection: keep-alive
Set-Cookie: JSESSIONID=10F426E45CEC8640F5853E3FB4760CC0; Path=/; Secure; HttpOnly
Access-Control-Allow-Origin: *
Set-Cookie: player-61646d696e=4; Max-Age=31536000; Expires=Mon, 30-Nov-2020 16:58:41 GMT; Path=/; HttpOnly
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-Frame-Options: SAMEORIGIN

gonic

curl --head "https://gonic.mydomain.com/rest/getAlbum.view?f=json&c=qooxtunes&v=1.15&u=USERNAME&s=OaUSpg&t=TOKEN&id=2"
HTTP/1.1 200 OK
Server: nginx/1.16.1
Date: Sun, 01 Dec 2019 16:59:05 GMT
Content-Type: application/json
Content-Length: 115
Connection: keep-alive
Access-Control-Allow-Headers: Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization
Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE
Access-Control-Allow-Origin: *

Any ideas what could be missing / different to cause this issue?

@sentriz
Copy link
Owner

sentriz commented Dec 1, 2019

hmm really not sure to be honest because the only header your thingy was complaining about CORS header ‘Access-Control-Allow-Origin’ missing
seems to be there

is your client open source? maybe I could try locally

@alex-phillips
Copy link
Author

It is: https://github.com/alex-phillips/qooxtunes

For ease of use, you can spin it up in docker with the following:

version: '3'
services:
  qooxtunes:
    container_name: qooxtunes
    image: alexphillips/qooxtunes
    ports:
      - 80:80
      - 443:443

@alex-phillips
Copy link
Author

Just FYI - the UI mimics old school iTunes, so it makes a TON of API calls to the backend server on startup to get the entire library worth of information (depending on the size of your library). Just fair warning :-P

@sentriz sentriz mentioned this issue Dec 5, 2019
@alex-phillips
Copy link
Author

Have you had a chance to check this out? I can send you a link of my running UI instance if that'll help troubleshoot.

@sentriz sentriz added the bug label Jan 21, 2020
@sentriz
Copy link
Owner

sentriz commented Jan 21, 2020

hi! sorry it's taken so long. I grabbed qooxtunes (looks very cool)

it seems the cors errors were only happening for views which are implemented yet (getStarred) because my NotFoundHandler (for the subsonic code 70) wasn't using the cors, or any other middleware.

funnily enough, this is already fixed on this branch:
https://github.com/sentriz/gonic/tree/param_refactor

which I hope to merge very shortly. see #14

@alex-phillips
Copy link
Author

@sentriz Great! Thanks for the update! Looking forward to the merge.

@sentriz
Copy link
Owner

sentriz commented Jan 22, 2020

hey that change should be on docker hub now. please re-open or make a new issue if something else has gone wrong. thanks!

@sentriz sentriz closed this as completed Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants