Search code examples
node.jsreactjsexpressweb-hostingmern

getting an error when deploying mern website to railway


i have a discord clone portfolio project at https://github.com/Inferno-Ripper/discord-clone i have deployed the frontend to vercel https://inferno-ripper-discord-clone.vercel.app, it works fine on firefox but it doesn't work on chrome and edge the network requests are stuck on pending. i have the backend hosted on railway, but when i try to deploy the frontend to railway it doesn't work i get this error

Build Logs on Railway

        ==============
        Using Nixpacks
        ==============
        Inline cache enabled
        no image tag to read cache from
        
        ╔═════════ Nixpacks v1.0.0 ═════════╗
        ║ setup      │ nodejs-16_x, npm-8_x ║
        ║───────────────────────────────────║
        ║ install    │ npm ci               ║
        ║───────────────────────────────────║
        ║ build      │ npm run build        ║
        ║───────────────────────────────────║
        ║ start      │ npm run start        ║
        ╚═══════════════════════════════════╝
        
        
        #1 [internal] load build definition from Dockerfile
        #1 sha256:8877270a0c7cc13a2a9d5d8d7622cdc0ed73b70ab957d081f5d2851376bd3d8b
        
        #1 transferring dockerfile: 2.08kB done
        #1 DONE 0.1s
        
        #2 [internal] load .dockerignore
        #2 sha256:2affaad88737ba21b452b724bb2eb7f99ebe9375f3ecc65cb617a265f26c24d8
        #2 transferring context:
        
        #2 transferring context: 2B done
        #2 DONE 0.2s
        
        #3 [internal] load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1671044363
        #3 sha256:d2df4677b7c4c8365aa628f14d4cbdd9867466b6b454c21060180de4b7936a2e
        
        #3 DONE 0.2s
        
        #4 [stage-0  1/10] FROM ghcr.io/railwayapp/nixpacks:ubuntu-1671044363@sha256:4df36f942799b8b727c8648ca4fa05d9cd2526e41e7994665082c0f7ef03d95b
        #4 sha256:a20b8f1ac783d9d00f7c673a9ef0cf3b8f0aaee89856a86f7aff78cda1934897
        #4 DONE 0.0s
        
        #5 [stage-0  2/10] WORKDIR /app/
        #5 sha256:46f35bb14209f31cddb6d0e80d42b3ceb58d2f45672a3486e22a069140ac06a3
        #5 CACHED
        
        #6 [internal] load build context
        #6 sha256:5648a1c35d09c4517e30329702fb9cb16d3deaa95854bbf8005030d88d65df40
        
        #6 transferring context: 1.35MB 0.0s done
        #6 DONE 0.1s
        
        #7 [stage-0  3/10] COPY .nixpacks/nixpkgs-ffca9ffaaafb38c8979068cee98b2644bd3f14cb.nix .nixpacks/nixpkgs-ffca9ffaaafb38c8979068cee98b2644bd3f14cb.nix
        #7 sha256:27a0f7b0a4acef0e435ab6d4d2af6e3163455490546099ce36a6ce8090fa6663
        #7 CACHED
        
        #8 [stage-0  4/10] RUN nix-env -if .nixpacks/nixpkgs-ffca9ffaaafb38c8979068cee98b2644bd3f14cb.nix && nix-collect-garbage -d
        #8 sha256:b14288120fda49c3952311baf2b490fed38e5c18b07a41507a8fa40b078b7061
        #8 CACHED
        
        #9 [stage-0  5/10] RUN printf '\nPATH=/app/node_modules/.bin:$PATH' >> /root/.profile
        #9 sha256:12dcf6a42bf1344db5b7a02483f2b846eaf2f6bd1e5f24337f79a8189bc2ff93
        
        #9 DONE 0.4s
        
        
        #10 [stage-0  6/10] COPY . /app/.
        #10 sha256:ce0a407cd50a1ccbe3be23e8717eb5b1978e54736f3716257765a0c50bc6ff1f
        #10 DONE 0.1s
        
        
        #11 [stage-0  7/10] RUN --mount=type=cache,id=s/b947d48a-6811-4bd7-be53-d870d96fde71-/root/npm,target=/root/.npm npm ci
        #11 sha256:292fe72abf96a75827c016a9bb758e94e0a7fc5724f193e1c1830ac7b3ac5920
        
        #11 0.730 npm WARN config
        production Use `--omit=dev` instead.
        
        #11 1.915 npm ERR! code ERESOLVE
        
        #11 1.919 npm ERR! ERESOLVE could not resolve
        #11 1.919 npm ERR!

Solution

  • it was a cors error, just needed to add these cookie options.

    {
            httpOnly: true,
            secure: true,
            sameSite: 'none',
    }