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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Logic For Rewriting URLs in JSON Response for Proxy #351

Open
GoPro16 opened this issue Oct 31, 2019 · 5 comments
Open

Add Logic For Rewriting URLs in JSON Response for Proxy #351

GoPro16 opened this issue Oct 31, 2019 · 5 comments

Comments

@GoPro16
Copy link
Contributor

GoPro16 commented Oct 31, 2019

馃殌 Feature request

Current Behavior

Any JSON response that comes back with contains a URL that points to the targetHost will not work if clicked via some Link component on an app because it will not be relative to localhost when developing.

Desired Behavior

The proxy should intercept the response before it reaches the UI, modify the URLs, if any exist, and then send it to the UI.

Suggested Solution

node-http-proxy-json looks to update this however, its not modifying the content-length which is why we had to revert #314

Example

With targetHost of http://www.helloworld.com

{
   "hello": "http://www.helloworld.com/test/123"
}

Should get modified to:

{
   "hello": "http://localhost:3000/test/123"
}

Once we can get the content-length updated it should work for all types of API responses.

Additional context

#350

@TheSharpieOne
Copy link
Collaborator

We only need to bump the version of node-http-proxy-json. Looks like the one that was used was really old.

@TheSharpieOne
Copy link
Collaborator

I suggest reverting 281a2d7 and just bumping the version of node-http-proxy-json.

@GoPro16
Copy link
Contributor Author

GoPro16 commented Oct 31, 2019

Still no dice on that

https://github.com/langjt/node-http-proxy-json/blob/master/index.js#L22-L24

langjt/node-http-proxy-json#10

We will have to manually change the content-length on another proxyRes step before returning.

@TheSharpieOne
Copy link
Collaborator

I don't see any manual change of the content-length within https://github.com/Availity/availity-workflow/blob/master/packages/workflow/scripts/proxy.js
The code that you linked is the code that makes this work with newer versions of node-http-proxy-json (by removing the content-length and thus there is no mismatch)

@GoPro16
Copy link
Contributor Author

GoPro16 commented Nov 1, 2019

I think api-core may be checking the content-length match then or something is bc I tested this out via @availity/workflow@canary and it still threw that error

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

No branches or pull requests

2 participants