Short description of issue
With recent updates to Chrome Local Network Access, there are now major CORS issues for any developers using vite to bundle their assets when developing themes.
Reproduction steps
A basic vite config should work like this, if using the popular vite-plugin-shopify:
import { defineConfig } from "vite"
import shopify from "vite-plugin-shopify"
export default defineConfig({
plugins: [
shopify({
themeRoot: "app",
sourceCodeDir: "src",
entrypointsDir: "src/entrypoints",
snippetFile: "vite-assets.liquid",
}),
],
})
After recent updates to Chrome the only way to correctly bundle assets is with a tunnel approach:
import { defineConfig } from "vite"
import shopify from "vite-plugin-shopify"
export default defineConfig({
plugins: [
shopify({
themeRoot: "app",
sourceCodeDir: "src",
entrypointsDir: "src/entrypoints",
snippetFile: "vite-assets.liquid",
tunnel: true,
}),
],
server: {
allowedHosts: true,
cors: {
origin: [
/^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/,
/^https?:\/\/[^/]+\.myshopify\.com$/,
],
},
Additional info
There has been a long discussion on the GitHub issue for here: Trouble with CORS only in Shopify Theme Editor · Issue #204 · barrel/shopify-vite · GitHub. Proposed solutions are sticking with a tunnel vite.config (works), disabling Chrome’s “Local Network Access” flag (works), and another dev says that if the editor’s iframe can have allow="local-network-access" added, the issue may be fixed.
I am wondering what the Shopify dev ream recommends here, or if they even are aware of this issue. Vite is an extremely popular tool for creating themes and the current DX is not good for theme development with these recent issues.
What type of topic is this
Troubleshooting