AmruthPillai / Reactive-Resume

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
https://rxresu.me
MIT License
26.29k stars 2.68k forks source link

[BUG] CORS header ‘Access-Control-Allow-Origin’ missing #1182

Open Xe138 opened 1 year ago

Xe138 commented 1 year ago

Describe the bug

The "Register" button on a new deployment fails due to a CORS related issue.

Product Flavor

To Reproduce

  1. Deploy the following using docker compose:
    
    version: "3.8"

services: postgres: image: postgres:alpine restart: always ports:

volumes: pgdata:

Note that the Postgres port is changed because I have an existing instance of Postgres running and the client port is changed due to other conflicts.
3. Open the client page (http://192.168.23.94:3004/)
4. Click "Register"
5. Complete the form and click "Register"

**Expected behavior**

Error-free registration of new account

**Logs**
Browser console

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://192.168.23.94:3100/auth/register. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 204.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://192.168.23.94:3100/auth/register. (Reason: CORS request did not succeed). Status code: (null).

Client Log

WARNING cannot find a .git folder. Falling back to manual file hashing (which may be slower). If you are running this build in a pruned directory, you can ignore this message. Otherwise, please initialize a git repository in the root of your monorepo

reactive-resume@3.6.17 start /app env-cmd --silent cross-var cross-env VERSION=$npm_package_version turbo run start "--filter" "client"

• Packages in scope: @reactive-resume/client • Running start in 1 packages • Remote caching disabled @reactive-resume/client:start: cache miss, executing 1028f534b516f6e4 @reactive-resume/client:start: @reactive-resume/client:start: > @reactive-resume/client@ start /app/client @reactive-resume/client:start: > react-env --prefix PUBLIC -- next start @reactive-resume/client:start: @reactive-resume/client:start: react-env: Writing runtime env /app/client/public/__ENV.js @reactive-resume/client:start: ready - started server on 0.0.0.0:3000, url: http://localhost:3000

Server Log

WARNING cannot find a .git folder. Falling back to manual file hashing (which may be slower). If you are running this build in a pruned directory, you can ignore this message. Otherwise, please initialize a git repository in the root of your monorepo

reactive-resume@3.6.17 start /app env-cmd --silent cross-var cross-env VERSION=$npm_package_version turbo run start "--filter" "server"

• Packages in scope: @reactive-resume/server • Running start in 1 packages • Remote caching disabled @reactive-resume/server:start: cache miss, executing d71d3a8879bdd9db @reactive-resume/server:start: @reactive-resume/server:start: > @reactive-resume/server@ start /app/server @reactive-resume/server:start: > node dist/main @reactive-resume/server:start: @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [NestFactory] Starting Nest application... @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] ConfigModule dependencies initialized +169ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] DatabaseModule dependencies initialized +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] TypeOrmModule dependencies initialized +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] MailModule dependencies initialized +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] PassportModule dependencies initialized +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] MulterModule dependencies initialized +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] MulterModule dependencies initialized +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] HttpModule dependencies initialized +2ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] CacheModule dependencies initialized +3ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] DiscoveryModule dependencies initialized +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] ConfigHostModule dependencies initialized +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] TerminusModule dependencies initialized +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] ServeStaticModule dependencies initialized +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] AppModule dependencies initialized +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] ScheduleModule dependencies initialized +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] ConfigModule dependencies initialized +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] ConfigModule dependencies initialized +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] HealthModule dependencies initialized +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] MailModule dependencies initialized +7ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] JwtModule dependencies initialized +60ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] PrinterModule dependencies initialized +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:47 PM LOG [InstanceLoader] FontsModule dependencies initialized +2ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [InstanceLoader] TypeOrmCoreModule dependencies initialized +258ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [InstanceLoader] TypeOrmModule dependencies initialized +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [InstanceLoader] TypeOrmModule dependencies initialized +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [InstanceLoader] UsersModule dependencies initialized +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [InstanceLoader] ResumeModule dependencies initialized +5ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [InstanceLoader] AuthModule dependencies initialized +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [InstanceLoader] IntegrationsModule dependencies initialized +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RoutesResolver] AuthController {/auth}: +13ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/auth, GET} route +6ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/auth/google, POST} route +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/auth/register, POST} route +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/auth/login, POST} route +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/auth/forgot-password, POST} route +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/auth/reset-password, POST} route +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/auth, DELETE} route +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RoutesResolver] ResumeController {/resume}: +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/resume, POST} route +2ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/resume, GET} route +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/resume/short/:shortId, GET} route +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/resume/:username/:slug, GET} route +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/resume/:id, GET} route +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/resume/:id, PATCH} route +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/resume/:id, DELETE} route +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/resume/:id/duplicate, POST} route +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/resume/:id/sample, POST} route +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/resume/:id/reset, POST} route +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/resume/:id/photo, PUT} route +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/resume/:id/photo, DELETE} route +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RoutesResolver] FontsController {/fonts}: +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/fonts, GET} route +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RoutesResolver] IntegrationsController {/integrations}: +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/integrations/linkedin, POST} route +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/integrations/json-resume, POST} route +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/integrations/reactive-resume, POST} route +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/integrations/reactive-resume-v2, POST} route +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RoutesResolver] PrinterController {/printer}: +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/printer/:username/:slug, GET} route +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RoutesResolver] HealthController {/health}: +1ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:48 PM LOG [RouterExplorer] Mapped {/health, GET} route +0ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:49 PM LOG [NestApplication] Nest application successfully started +1610ms @reactive-resume/server:start: [Nest] 105 - 01/15/2023, 7:33:49 PM LOG 🚀 Server is up and running!

Database Log

2023-01-15 19:20:12.966 UTC [1] LOG: starting PostgreSQL 15.1 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924, 64-bit 2023-01-15 19:20:12.966 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2023-01-15 19:20:12.966 UTC [1] LOG: listening on IPv6 address "::", port 5432 2023-01-15 19:20:13.005 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2023-01-15 19:20:13.061 UTC [24] LOG: database system was shut down at 2023-01-15 19:19:40 UTC 2023-01-15 19:20:13.084 UTC [1] LOG: database system is ready to accept connections 2023-01-15 19:25:13.161 UTC [22] LOG: checkpoint starting: time 2023-01-15 19:25:22.548 UTC [22] LOG: checkpoint complete: wrote 89 buffers (0.5%); 0 WAL file(s) added, 0 removed, 0 recycled; write=8.622 s, sync=0.708 s, total=9.387 s; sync files=52, longest=0.032 s, average=0.014 s; distance=299 kB, estimate=299 kB 2023-01-15 19:35:13.698 UTC [22] LOG: checkpoint starting: time 2023-01-15 19:35:15.266 UTC [22] LOG: checkpoint complete: wrote 14 buffers (0.1%); 0 WAL file(s) added, 0 removed, 0 recycled; write=1.404 s, sync=0.112 s, total=1.568 s; sync files=8, longest=0.019 s, average=0.014 s; distance=23 kB, estimate=272 kB


**Desktop (please complete the following information):**

- OS: Unraid 6.11.5
- Browser: Firefox
- Version: Reactive Resume 3.6.17
ykorzikowski commented 1 year ago

EDIT: Nevermind below. See https://github.com/AmruthPillai/Reactive-Resume/issues/1174#issuecomment-1401813802

If you using nginx, you can solve this by adding

    add_header 'Access-Control-Allow-Origin' 'https://cv.***.com';

to the api-server-block.

server {
    listen *:80;
    listen [::]:80;
    server_name cv.***.com;

    location / {
        return 301 https://cv.***.com$request_uri;
    }
}
server {
    include security.conf;
    listen *:443 ssl;
    listen [::]:443 ssl;
    ssl_certificate /etc/letsencrypt/live/***.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/***.com/privkey.pem;
    server_name cv-api.***.com;

    add_header 'Access-Control-Allow-Origin' 'https://cv.***.com';

    access_log      /var/log/nginx/***.com/cv-api.log;
    error_log       /var/log/nginx/***.com/err/cv-api.log;

    location / {
       proxy_pass http://10.10.10.116:19001/;

       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "upgrade";
       proxy_set_header Host $http_host;

       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto https;
       proxy_set_header X-Nginx-Proxy true;

       proxy_redirect off;
    }

}

server {
    include security.conf;
    listen *:443 ssl;
    listen [::]:443 ssl;
    ssl_certificate /etc/letsencrypt/live/***.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/***.com/privkey.pem;
    server_name cv.***.com;

    access_log      /var/log/nginx/***.com/cv.log;
    error_log       /var/log/nginx/***.com/err/cv.log;

    #### BEGIN SSO BLOCK ####

    resolver 10.10.10.104;

    access_by_lua '
      assert(loadfile("/etc/nginx/snippets/keycloak_auth.lua"))()
      startSSO(ngx, false)
    ';

    #### END SSO BLOCK ####

    location / {
       proxy_pass http://10.10.10.116:19000/;

       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "upgrade";
       proxy_set_header Host $http_host;

       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto https;
       proxy_set_header X-Nginx-Proxy true;

       proxy_redirect off;
    }
}
ykorzikowski commented 1 year ago

EDIT: Nevermind below. See https://github.com/AmruthPillai/Reactive-Resume/issues/1174#issuecomment-1401813802

But somehow when trying to print the pdf, its failing because of CORS:

@reactive-resume/server:start:     at PrinterService.printAsPdf (/app/server/dist/printer/printer.service.js:59:24)
@reactive-resume/server:start: [Nest] 101  - 01/24/2023, 10:25:40 AM   ERROR [ExceptionsHandler] page.waitForSelector: Timeout 30000ms exceeded.
@reactive-resume/server:start: =========================== logs ===========================
@reactive-resume/server:start: waiting for locator('html.wf-active') to be visible
@reactive-resume/server:start: ============================================================
@reactive-resume/server:start: page.waitForSelector: Timeout 30000ms exceeded.