0

I'm trying to deploy my application on vercel through a GitHub workflow that runs whenever the code is pushed onto the remote repository. The workflow is successfully running, but when I visit the deployed link, an empty white page is shown. On inspecting the network tabs, I could see that the request to the URL is returning a 304 status code. I'm quite clueless why this is happening. Below is the folder structure of my project.

Below is my workflow file

name: Preview Deployment
env:
  VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
  VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
  push:
    branches-ignore:
      - release
jobs:
  Deploy-Preview:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install Vercel CLI
        run: npm install --global vercel@latest
      - name: Pull Vercel Environment Information
        run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
      - name: Build Project Artifacts
        run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
      - name: Deploy Project Artifacts to Vercel
        run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}

During the build step, I could also notice the following log along with some other warnings:

Failed to load ./.env.

Despite the warnings(mostly related to the build file size being over the recommended size) and the above log, the build is successful. How do I fix this 304 issue? TIA

Further, to verify things, I also built the application locally and tried running it, and it worked as expected.

Prajwal Kulkarni
  • 1,480
  • 13
  • 22
  • Do you see any logs for the successful deployment? – Azeem Feb 19 '23 at 11:27
  • @Azeem yes I do. This is the log that I see in the build artifact `webpack 5.75.0 compiled with 3 warnings in 34104 ms Done in 35.85s. Build Completed in .vercel/output [2m]` and a deployed message. UPDATE: I restructured my repository to host just the frontend code, but I'm still facing the same issue. – Prajwal Kulkarni Feb 19 '23 at 14:18
  • You might want to verify the deployed files on the server. Also, you might want to further debug the [HTTP 304](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304) status code. – Azeem Feb 19 '23 at 14:31
  • Any heads up on how do I go about this? The deployed files on the server seem to be fine. – Prajwal Kulkarni Feb 19 '23 at 14:38
  • Did you check their timestamps and correlate those with the deployment time? – Azeem Feb 19 '23 at 14:46
  • Yes, looks alright. However, just observed a strange behavior now. When the application is deployed via workflow, the `.vercel` directory contains only assets like favicons and images along with `builds.json` and `configs.json`. But, when I try deploying directly from my local environment by running `vercel --prod`, I can see all the files on the server, but in both cases, I'm seeing the 304 status code with an empty white page being rendered. – Prajwal Kulkarni Feb 19 '23 at 14:54
  • Right. This looks relevant: https://stackoverflow.com/questions/73390663/next-app-deployed-on-vercel-request-for-new-refresh-token-leads-to-unwanted-304. – Azeem Feb 19 '23 at 15:00
  • But, isn't the `refresh` API specific only to apps built with Next.js? I'm using a pure react, and, moreover aren't we supposed to define cache control rules on the backend? – Prajwal Kulkarni Feb 19 '23 at 15:11
  • Well, the gist from that [thread](https://stackoverflow.com/questions/73390663/next-app-deployed-on-vercel-request-for-new-refresh-token-leads-to-unwanted-304) is that you have to disable caching on that server. – Azeem Feb 19 '23 at 15:18
  • Also, how are you testing it? Google Chrome? Normal or incognito? You should test it in incognito mode. – Azeem Feb 19 '23 at 15:20
  • 1
    Yes, I'm testing in Incognito. The issue is now fixed. I just had to override the output directory which was either `public` or `./` by default to `dist`, and maybe due to this reason there was nothing really to load since this result was cached, I might've likely been getting 304. Anyway, thanks a lot for the reference and help. Appreciated! :) – Prajwal Kulkarni Feb 19 '23 at 15:44
  • 1
    Awesome! Sure, no problem. You might want to self-answer this with all the details to help future readers. All the best! – Azeem Feb 19 '23 at 15:58
  • Yes, sure. I'll do it! – Prajwal Kulkarni Feb 19 '23 at 17:47

0 Answers0