Skip to content

CORS issue when running npm start #600

Open
@ja5o

Description

@ja5o

Describe the bug
I've done all the steps described on the Get Started page, changed the wordpressHost to my development URL but when I go and run the start command, everything seems to be working, but I can't see images or any resource in the front end, and I get the following error in the browser console

Access to script at 'http://localhost:5173/assets/main.js' from origin 'http://mysite.test' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

If I run the build command everything work alright.

To Reproduce
Steps to reproduce the behavior:

  1. Download the most recent copy of the theme
  2. Change the wordpressHost constant
  3. Run the start command
  4. See error

Expected behavior
Assets are visible on the front end

Desktop (please complete the following information):

  • OS: MacOS 15.5
  • Browser: Arc
  • Version: 1.97.1 (63934) / Chromium Engine Version 137.0.7151.69

Additional context

  • Running Node 20.16.0
  • Using pnpm
  • Using Laravel Valet

If I add the following to vite.config.js server object it seems to work, but this is my first time working with Vite and Flynt, so I'm not sure if is okay to do this.

cors: {
        origin: host,
        credentials: true,
      }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions