Skip to content

fix: Sync load scripts in webviews to fix CORS

Paul Slaughter requested to merge ps-fix-cors into main

Description

This MR fixes Duo Chat for Self-Managed by removing the need for CORS loading the script. This was an issue because of type="module" that is automatically added by Vite.

Vite makes a huge assumption that moving all scripts to the head and adding type="module" is safe.

In reality this transforms the request from a no-cors to a cors which is big issue in these VSCode webviews since they have to run in a separate origin.

Related Issues

How has this been tested?

  1. Using Run Extension in VSCode project
  2. In the Web IDE by creating an MR updating gitlab-vscode-extension to this MR branch and running create-development-package then updating the main GitLab 'package.json` to point to that development package

Screenshots (if appropriate)

On Desktop:

Still works
Screenshot_2024-02-14_at_1.03.39_AM

On Web IDE in GDK:

Patch to enable duo_chat
diff --git a/ee/app/graphql/resolvers/ai/user_chat_access_resolver.rb b/ee/app/graphql/resolvers/ai/user_chat_access_resolver.rb
index 4f655e182636..76f5286e1fd1 100644
--- a/ee/app/graphql/resolvers/ai/user_chat_access_resolver.rb
+++ b/ee/app/graphql/resolvers/ai/user_chat_access_resolver.rb
@@ -6,6 +6,7 @@ class UserChatAccessResolver < BaseResolver
       type ::GraphQL::Types::Boolean, null: false
 
       def resolve
+        return true
         return false unless current_user
 
         Feature.enabled?(:ai_duo_chat_switch, type: :ops) &&

Screenshots
Before After
Screenshot_2024-02-14_at_1.07.15_AM Screenshot_2024-02-14_at_1.11.16_AM

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation
  • Chore (Related to CI or Packaging to platforms)
  • Test gap
Edited by Paul Slaughter

Merge request reports

Loading