Code Monkey home page Code Monkey logo

Comments (4)

sheastyer avatar sheastyer commented on June 2, 2024 1

Turns out, I was unable to repro this when connecting directly to the proxy. I am not too worried, the whole point of the reverse proxy is to get all requests to be same-origin when hosted, so this won't be an issue besides local dev. And we can use a non-reverse-proxied unleash proxy there. Thanks for the help @nya1!

from unleash-proxy.

sheastyer avatar sheastyer commented on June 2, 2024

@nya1 Any input here? Looks like this was added pretty recently #4

from unleash-proxy.

nya1 avatar nya1 commented on June 2, 2024

Hello,
Are you able to provide the error that you receive on the browser?
I tried to reproduce the issue locally following the mentioned steps but I'm always getting back the Access-Control-Allow-Origin header, examples requests made with curl (I also tested via an html page and getting the same behavior):

❯ curl -I --location --request GET 'http://localhost:3000/proxy?userId=99' \
-H 'Origin: http://example.com' \
-H 'Authorization: some-secret'
HTTP/1.1 200 OK
Access-Control-Allow-Origin: http://example.com
Vary: Origin, Accept-Encoding
Cache-control: public, max-age=2
Content-Type: application/json; charset=utf-8
Content-Length: 9299
ETag: W/"2453-1yoqHWPP3DU/zVKAUXQQ02ygZQ0"
Date: Fri, 15 Jul 2022 11:50:48 GMT
Connection: keep-alive
Keep-Alive: timeout=5

❯ curl -I --location --request GET 'http://localhost:3000/proxy?userId=99' \
-H 'Origin: http://example.com' \
-H 'Authorization: some-secret' \
-H 'if-none-match: W/"2453-1yoqHWPP3DU/zVKAUXQQ02ygZQ0"'
HTTP/1.1 304 Not Modified
Access-Control-Allow-Origin: http://example.com
Vary: Origin
Cache-control: public, max-age=2
ETag: W/"2453-1yoqHWPP3DU/zVKAUXQQ02ygZQ0"
Date: Fri, 15 Jul 2022 11:50:52 GMT
Connection: keep-alive
Keep-Alive: timeout=5

Cors options used: (tested also using localhost)

    cors: {
        origin: 'http://example.com',
    }

p.s. probably it's a typo but the Access-Control-Allow-Origin response header that you receive should be the same as the one that you have entered during cors initialization (the same location where your webapp is located), so in your case should return http://localhost:3000 and not http://localhost:3001

from unleash-proxy.

sheastyer avatar sheastyer commented on June 2, 2024

Hi @nya1 I was able to still repro the issue with your exact requests

first request

➜  ~ curl --location --request GET 'https://redacted/proxy?userId=myUser2' -i \
--header 'Origin: http://example.com' \
--header 'Authorization: redacted'
HTTP/2 200 
access-control-allow-origin: http://localhost:3001
cache-control: public, max-age=2
content-type: application/json; charset=utf-8
etag: W/"87-/cEiJdy7BgvCABHt6xVgsypDIcs"
via: 1.1 spaces-router (b642bf20b975), 1.1 varnish
accept-ranges: bytes
date: Fri, 15 Jul 2022 15:41:36 GMT
age: 0
x-served-by: cache-pao17421-PAO
x-cache: MISS
x-cache-hits: 0
x-timer: S1657899697.549769,VS0,VE256
vary: Origin, Accept-Encoding
content-length: 135

second request

➜  ~ curl --location --request GET 'https://redacted/proxy?userId=myUser2' -i \
--header 'Origin: http://example.com' \
--header 'Authorization: redacted' \
--header 'if-none-match: W/"87-/cEiJdy7BgvCABHt6xVgsypDIcs"'
HTTP/2 304 
date: Fri, 15 Jul 2022 15:44:40 GMT
via: 1.1 varnish
cache-control: public, max-age=2
etag: W/"87-/cEiJdy7BgvCABHt6xVgsypDIcs"
age: 0
x-served-by: cache-sjc10020-SJC
x-cache: MISS
x-cache-hits: 0
x-timer: S1657899880.429934,VS0,VE191
vary: Origin, Accept-Encoding

I do have another Unleash environment running without the reverse proxy - I will try and see if I can repro there.

from unleash-proxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.