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 Error, Port number did not reflected when change in build script #389

Open
codenamewei opened this issue May 29, 2021 · 3 comments
Open
Labels
bug Something isn't working medium priority need to fix, it block some features function

Comments

@codenamewei
Copy link
Contributor

codenamewei commented May 29, 2021

Describe the bug
Port number in front end did not change when changed it in the build script

To Reproduce

  1. Download Classifai Repo
  2. Run
Unix: ./startClassifai.sh --port=12222
Windows: startClassifai.bat --port=12222
  1. In web browser, use inspect to see the URL endpoints called
    It can be seen that the url still maps back to 9999

Screenshot 2021-05-29 at 6 23 24 PM

Expected behavior
Port of endpoints changed accordingly with build script when port number is specifically written.

Desktop (please complete the following information):
Tested on Mac.

@amalsyahmi-certifai can you check if you are seeing the same scenario im facing,
as of assignee to solve the bug, you can decide who to work on it

@codenamewei codenamewei added the bug Something isn't working label May 29, 2021
@codenamewei codenamewei added the medium priority need to fix, it block some features function label May 29, 2021
@daniellim07
Copy link
Contributor

daniellim07 commented May 29, 2021

@codenamewei Based on the screenshot, this should not be an issue on the web app.
Build script would only change web app's port number (For instance, originally 4200 and you changed it to 12222).

The error message on CORS stated port 9999, has no relation to build script from web app. Note that port 9999 is coming from web app's production environment variable.

In summary, web app with port 12222 is talking to backend with port 9999. But backend does not enable CORS for port 12222, which means by default the backend would only allow same port to communicate with it, which does not involves CORS policy being violated.

The best way to overcome (for localhost situation) is to have CORS to whitelist with wildcard implementation, as you guys would keep changing the web app port.

@codenamewei
Copy link
Contributor Author

codenamewei commented May 29, 2021

@daniellim07 do you mean by doing wildcard search something like

router.route().handler(io.vertx.ext.web.handler.CorsHandler.create(".*.")

?

yeah we could not prevent people from the possibillity of changing port..

its very unlikely but possibly people by need to change port due to another application occupying the default port at the first place.

@daniellim07
Copy link
Contributor

@codenamewei Yes, but also need the following code like the ones I had provided back then in Slack channel.
As CORS policy is very strict, any missing headers or method & etc will result in preventing backend from accepting request coming from web app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working medium priority need to fix, it block some features function
Projects
None yet
Development

No branches or pull requests

3 participants