Closed Maikpwwq closed 1 year ago
You can't use formAction$
with static content. There is no server, it is SSG. This can't work. You need to deploy to edge environment to use formAction$
.
Ok, so I update my Form project to use Vercel Edge Adapter
witch disable that SSG. I also have installed and implemented polyfills to vite.config.js
using plugin import { nodePolyfills } from 'vite-plugin-node-polyfills'
. Is important to notice that some packages needs to be pre-processed by Vite in production using noExternal
. My file vite.config.ts
:
import { defineConfig } from "vite";
import { qwikVite } from "@builder.io/qwik/optimizer";
import { qwikCity } from "@builder.io/qwik-city/vite";
import tsconfigPaths from "vite-tsconfig-paths";
import { qwikReact } from "@builder.io/qwik-react/vite";
import { nodePolyfills } from 'vite-plugin-node-polyfills'
const isProd = process.env.NODE_ENV === 'production'
const noExternal: string[] = []
if (isProd) {
noExternal.push(
...[
// Needs to be pre-processed by Vite in production
'@mui/base',
'@mui/icons-material',
'@mui/material',
'@mui/utils',
'@mui/x-data-grid',
'@emotion/react',
'@emotion/styled',
'mongodb',
'mongoose',
'uuid',
'clsx',
'undici',
'@supabase*',
]
)
}
export default defineConfig(() => {
return {
plugins: [
nodePolyfills({
// To exclude specific polyfills, add them to this list.
exclude: [
'fs', // Excludes the polyfill for `fs` and `node:fs`.
],
// Whether to polyfill specific globals.
globals: {
Buffer: true, // can also be 'build', 'dev', or false
global: true,
process: true,
},
// Whether to polyfill `node:` protocol imports.
// protocolImports: true,
}),
qwikCity(), qwikVite(), tsconfigPaths(), qwikReact()
],
preview: {
headers: {
"Cache-Control": "public, max-age=600",
},
},
ssr: {
noExternal
},
};
});
In my local the project works well, for both forms storing data with MongoDB and with Supabase. But In Vercel deployed version
it not works yet.
Can you send me a URL to the deplayed application so I can better understand what the browser is seeing?
@mhevery this is my vercel domain https://qwik-app-psi-sable.vercel.app/
Here is a simple
repo with routeAction$ and it's working like a charm.
GH Repo
Vercel deploy
SSG this because Vercel use static content
This is not true, Vercel has SSR too. Please use the Vercel integration
Here is a
simple
repo with routeAction$ and it's working like a charm. GH Repo Vercel deploy
I watched your code example implementing routeAction$, but that async function
you created doesn't make any await call
, qwik render correctly the form and the client interaction, even though I am facing issues with the server when publishing my changes into DB.
SSG this because Vercel use static content
This is not true, Vercel has SSR too. Please use the Vercel integration
How I comment previously, currently my project was updated and now it uses Vercel Edge Adapter
.
I was no clear about that, I first try to deploy in netlify, but have issues because there is no index.html file in Qwik projects required by the static host. That was why I tried with static generation in my Qwik project.
routeAction$ is working. Let's continue this discussion in Qwik Discord, this is not the right place for this kind of assistance.
Which component is affected?
Qwik City (routing)
Describe the bug
I have created a minimal reproduction in a Qwik empty project, using the static adapter. Take a look first:
Github Project Repository Vercel Project
Get Code
Take into account I am trying to build just a simple Form in Qwik. I just need to sent it, that's because I am using my keys to access Mongo Or Supabase.
Reproduction
https://github.com/Maikpwwq/qwik-ssg-modular-forms
Steps to reproduce
Follow those steps to create Qwik empty project, then use
pnpm run qwik add
to add adapter to SSG this because Vercel use static content. Then create modular-forms: It works in local, when it is deployed to Vercel doesn't works.System Info
Additional Information
No response