AFFiNE icon indicating copy to clipboard operation
AFFiNE copied to clipboard

fix: try redirecting api requests in electron

Open pengx17 opened this issue 2 years ago • 6 comments

This PR tries to use protocol.handle to redirect /api and /graphql requests to CLOUD_URL. However the attempt was blocked:

  • when using file:// scheme, it seems we cannot overwrite it with protocol.handle. see https://github.com/electron/electron/issues/39031
  • when using assets:// scheme, the message from render to helper cannot be intercepted.

In either way, the proposal seems to be stuck at the moment. Alternatively and maybe more reasonably, we shall add prefix urls to fetch usage in the renderer, instead of calling /api/xxx instead.

pengx17 avatar Jul 10 '23 16:07 pengx17

This branch is running in CodeSandbox. Use the links below to review this PR faster.
CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders | Preview

codesandbox[bot] avatar Jul 10 '23 16:07 codesandbox[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
affine-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 10, 2023 4:40pm
affine-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 10, 2023 4:40pm
affine-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 10, 2023 4:40pm

vercel[bot] avatar Jul 10 '23 16:07 vercel[bot]

Codecov Report

Patch coverage has no change and project coverage change: -1.87 :warning:

Comparison is base (812e0e9) 67.85% compared to head (69311a9) 65.98%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3136      +/-   ##
==========================================
- Coverage   67.85%   65.98%   -1.87%     
==========================================
  Files         347      345       -2     
  Lines        8293     8267      -26     
  Branches     1074     1068       -6     
==========================================
- Hits         5627     5455     -172     
- Misses       2380     2518     +138     
- Partials      286      294       +8     
Flag Coverage Δ
e2etest 57.03% <ø> (+0.06%) :arrow_up:
e2etest-macos-latest-x64 ?
e2etest-ubuntu-latest-x64 ?
e2etest-windows-latest-x64 ?
server-test 79.00% <ø> (ø)
unittest 56.18% <ø> (+0.03%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

see 46 files with indirect coverage changes

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Jul 10 '23 16:07 codecov[bot]

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 69311a9
Status: ✅  Deploy successful!
Preview URL: https://9139bd5f.affine-dev.pages.dev
Branch Preview URL: https://xp-0711-fix-protocol.affine-dev.pages.dev

View logs

affine-toeverything

Bundle main

diff ------------------- Bundle Size Diff -------------------------

@@                       EntryPoint: main                        @@
##                     master …/fix/protocol                 +/- ##
===================================================================
> Bundle              5.26 MB        5.25 MB    -11.3 kB(-0.21%)   
> Initial JS          2.23 MB        2.23 MB    -2.64 kB(-0.12%)   
= Initial CSS         72.8 kB        72.8 kB                       
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
= Assets                   71             71                       
= Chunks                   57             57                       
= Packages                207            207                       
= Duplicates               19             19                       
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Warnings ~~~~~~~~~~~~~~~~~~~~~~~~~~~#
! Deduplicate versions of libraries                                
! Separate mixed content assets files                              
! Avoid cache wasting                                              

@@                    EntryPoint: pages/_app                     @@
##                     master …/fix/protocol                 +/- ##
===================================================================
> Bundle              5.16 MB        5.14 MB    -11.3 kB(-0.22%)   
> Initial JS          2.12 MB        2.12 MB    -2.64 kB(-0.12%)   
= Initial CSS         72.8 kB        72.8 kB                       
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
= Assets                   69             69                       
= Chunks                   55             55                       
= Packages                207            207                       
= Duplicates               19             19                       
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Warnings ~~~~~~~~~~~~~~~~~~~~~~~~~~~#
! Deduplicate versions of libraries                                
! Separate mixed content assets files                              
! Avoid cache wasting                                              

@@                   EntryPoint: pages/_error                    @@
##                     master …/fix/protocol                 +/- ##
===================================================================
= Bundle              16.6 kB        16.6 kB                       
= Initial JS          16.6 kB        16.6 kB                       
= Initial CSS             0 B            0 B                       
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
= Assets                    2              2                       
= Chunks                    2              2                       
= Packages                  5              5                       
= Duplicates                0              0                       

...and more

perfsee[bot] avatar Jul 10 '23 16:07 perfsee[bot]

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 69311a9d319bfd29312f15382ea509e9dd3c7713. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

nx-cloud[bot] avatar Jul 10 '23 17:07 nx-cloud[bot]

Closed in https://github.com/toeverything/AFFiNE/pull/3178

himself65 avatar Jul 12 '23 05:07 himself65