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

Fixed cors origin port issue #59

Closed
wants to merge 37 commits into from
Closed

Conversation

lukyanov
Copy link

@lukyanov lukyanov commented Apr 10, 2017

Ledest and others added 28 commits April 3, 2016 02:51
It returns allowed headers for preflight requests and
sets the header `access-control-allow-headers`.
…ication/msgpack", "application/x-www-form-urlencoded"
@tommyjcarpenter
Copy link

tommyjcarpenter commented Sep 12, 2017

Does this fix it? What does cross_domains callback value need to be?

I'm currently using:

cross_domains(_Route, _Req, State) ->
    {['_'], State}.

No port works:

curl -H "Origin: http://mydomain.com" --verbose localhost:7777/application/
*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 7777 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 7777 (#0)
> GET /application/ HTTP/1.1
> Host: localhost:7777
> User-Agent: curl/7.54.0
> Accept: */*
> Origin: http://mydomain.com
>
< HTTP/1.1 200 OK
< connection: keep-alive
< server: Cowboy
< date: Tue, 12 Sep 2017 15:20:51 GMT
< content-length: 2
< content-type: application/json
< access-control-allow-origin: http://mydomain.com
<
* Connection #0 to host localhost left intact
[]⏎      

Port does not work:

curl -H "Origin: http://mydomain.com:8000" --verbose localhost:7777/application/
*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 7777 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 7777 (#0)
> GET /application/ HTTP/1.1
> Host: localhost:7777
> User-Agent: curl/7.54.0
> Accept: */*
> Origin: http://mydomain.com:8000
>
< HTTP/1.1 500 Internal Server Error
< connection: keep-alive
< server: Cowboy
< date: Tue, 12 Sep 2017 15:20:53 GMT
< content-length: 0
<
* Connection #0 to host localhost left intact

@tommyjcarpenter
Copy link

Sorry my bad. I didn't rebar3 upgrade. I can confirm this fixes it. Thank you!

I brought this into my own fork which upgrades the jiffy version.


{deps, [
{cowboy, ".*", {git, "git://github.com/extend/cowboy.git", {tag, "0.9.0"}}},
{jiffy, ".*", {git, "git://github.com/davisp/jiffy.git", {tag, "0.8.5"}}},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naive question.. what is the effect of removing jiffy here? I am using a combination of leptus and Jiffy in a few projects; is Jiffy completely interchangeable with msgpack, such that jiffy + leptus 1.0.0 (your proposal here) is fine?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. I didn't meant this PR be such big. It is actually my mistake as I initially made a PR from my master branch. Now I added a lot of stuff to my master and it all appeared here. I'm going to close this PR.

As regards to your question, jiffy has been removed as an alternative to jsx (https://github.com/talentdeficit/jsx.git). leptus originally supported two different JSON libraries, in my changes it supports only one (jsx). msgpack is still supported as before.

@lukyanov lukyanov closed this Nov 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants