Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS issue with build when using DDEV (docker) #21

Open
tyler36 opened this issue Sep 6, 2024 · 0 comments
Open

CORS issue with build when using DDEV (docker) #21

tyler36 opened this issue Sep 6, 2024 · 0 comments

Comments

@tyler36
Copy link

tyler36 commented Sep 6, 2024

I finally got around to giving this is a good go on CakePHP5.
However, I'm hitting a CORS issue when I run build, but not dev.

I'm using DDEV to serve my CakePHP and have the following vite.config.js

const port = 5173
const origin = `${process.env.DDEV_PRIMARY_URL}:${port}`

// https://vitejs.dev/config/
export default defineConfig({
  build: {
    emptyOutDir: false,
    outDir: './webroot',
    manifest: true,
    rollupOptions: {
      input: './webroot_src/main.ts',
    },
  },
  server: {
    host: '0.0.0.0',
    port: port,
    origin: origin,
    strictPort: true,
    watch: {
      usePolling: true,
    },
  },
})

combined with app_vite.php

return [
    'ViteHelper' => [
      'development' => [
        'hostNeedles' => [
          'localhost',
           '.site'
        ],
        'url' => 'https://cake5-vanilla.ddev.site:5173',
      ],
    ],
];

This works when I run dev.
When I use build, it sees .site in the host and thinks its running a DEV server and fails. If I comment out the hostNeedles, build works but dev does not.

Not sure where exactly the issue lies, but any insight would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant