microsoft / showwhy

MIT License
200 stars 28 forks source link

Disable CORS for local deployments #428

Open priamai opened 10 months ago

priamai commented 10 months ago

Hello, we need to find a way to disable CORS for local deployments otherwise it's impossible to use.

image

v-shaal commented 10 months ago

➕➕

dayesouza commented 10 months ago

Hi guys! I guess it's not CORS, but a backend problem. Can you send me the call Response on the network tab, please?

priamai commented 10 months ago

Hmmm it is weird, but I do believe is a simple CORS issue:

image

image

There is no response from server because is blocked.

image

But from the docker logs:

showwhy-frontend-1        | @showwhy/webapp:start: Entrypoint main 24.3 MiB (20.5 MiB) = main.ff838458f89b87c18d99.js 24.3 MiB main.04dc6812f929d7051131.hot-update.js 360 bytes 2 auxiliary assets
showwhy-frontend-1        | @showwhy/webapp:start: cached modules 21.4 MiB [cached] 8017 modules
showwhy-frontend-1        | @showwhy/webapp:start: runtime modules 34 KiB 18 modules
showwhy-frontend-1        | @showwhy/webapp:start: webpack 5.75.0 compiled successfully in 2222 ms
showwhy-backend_api-1     | INFO:     192.168.2.23:43620 - "OPTIONS /api/discover/pc HTTP/1.1" 400 Bad Request

The error is a 400 which matches the browser info:


Request URL:
http://kausal.ai:8081/api/discover/pc
Request Method:
OPTIONS
Status Code:
400 Bad Request
Remote Address:
192.168.2.25:8081
Referrer Policy:
strict-origin-when-cross-origin
dayesouza commented 10 months ago

Thanks for the images! I'm trying to build it here again because up to this day I couldn't get the same error, I'll check here

priamai commented 10 months ago

Thanks a lot so this is the command I used:

yarn install
yarn build # or yarn force_build
yarn start

This is the only file I modified, the package.json I changed the host to my local domain:

{
    "name": "showwhy",
    "private": true,
    "version": "2.0.0",
    "description": "MSR Resilience Causal Platform",
    "main": "index.js",
    "repository": "git@ssh.dev.azure.com:v3/msresearch/Resilience/causal-platform",
    "author": "Chris Trevino <chtrevin@microsoft.com>",
    "license": "UNLICENSED",
    "scripts": {
        "_acceptance_test_packages": "turbo run acceptance_test",
        "_fix_packages": "turbo run fix",
        "_check_packages": "turbo run check",
        "_ci_packages": "turbo run ci",
        "rome_fix": "rome check . --apply-suggested",
        "rome_ci": "rome ci .",
        "clean": "turbo run clean --parallel",
        "assets": "turbo run assets",
        "build": "turbo run build",
        "force_build": "turbo run build --force",
        "archive": "turbo run archive",
        "poetry_install": "turbo run poetry_install --parallel",
        "check": "run-s _check_packages rome_ci",
        "fix": "run-s _fix_packages rome_fix format",
        "format": "rome format . --write",
        "test": "turbo run test",
        "ci": "run-s _ci_packages rome_ci",
        "acceptance_test": "start-server-and-test start http://kausal.ai:3000 _acceptance_test_packages",
        "start_webapps": "echo 'use the start_frontend command instead' && exit 1'",
        "start_frontend": "cross-env EXPOSURE_API_URL=http://kausal.ai:8081/api/exposure DISCOVER_API_URL=http://kausal.ai:8081/api/discover EVENTS_API_URL=http://kausal.ai:8081/api/events turbo run start --parallel",
        "start_frontend_raw": "turbo run start --parallel",
        "start": "docker compose --profile all up",
        "start_fresh": "docker compose --profile all build && docker compose --profile all up",
        "start_backend": "docker compose --profile backend up",
        "start_backend_fresh": "docker compose --profile backend build && docker compose --profile backend up",
        "deploy": "turbo run deploy",
        "is_clean": "git checkout .npmrc && git diff-index HEAD --quiet || (git status && error_not_clean)",
        "prettify": "essex prettify",
        "stories": "yarn start:storybook",
        "update_sdks": "yarn dlx @yarnpkg/sdks vscode"
    },
    "devDependencies": {
        "@essex/eslint-config": "^20.5.1",
        "@essex/eslint-plugin": "^20.5.1",
        "@essex/jest-config": "^21.0.20",
        "@essex/prettier-config": "^18.0.7",
        "@essex/scripts": "^24.0.2",
        "cross-env": "^7.0.3",
        "eslint": "^8.32.0",
        "jest": "^29.4.0",
        "npm-run-all": "^4.1.5",
        "prettier": "^2.8.3",
        "rome": "^11.0.0",
        "start-server-and-test": "^1.15.3",
        "turbo": "1.6.3",
        "typescript": "^4.9.4"
    },
    "workspaces": [
        "javascript/*"
    ],
    "packageManager": "yarn@3.3.1"
}