Look at the nuxt 3 documentation and Nuxt Ionic Documentationto learn more.
alertController
and actionSheetController
SSR = false
to generate the output that is needed for capacitor to build appionic:build:env BUILD_MOBILE=true npx nuxt generate
package.json
, env BUILD_MOBILE=true npx nuxt generate
if build mobile is true then I do two things in the nuxt.config.ts
.
export default defineNuxtConfig({
modules: ["@nuxtjs/ionic"],
ssr : process.env.BUILD_MOBILE === "true" ? false : true, // set the ssr value
appConfig : {
API_SERVER_URL :process.env.BUILD_MOBILE === "true" ? process.env.SERVER_URL : "/", // set api url
},
ionic: {
integrations: {
pwa: false,
},
css: {
basic: true,
core: true,
utilities: true,
},
}
});
SERVER_URL
to point to where the server api is hostedadded environment variable that is not set set in package.json
, BUILD_MOBILE
if build mobile is not defined then I do two things in the nuxt.config.ts
/
// server/middleware/cors.ts
// https://github.com/nuxt/nuxt/issues/14598#issuecomment-1397361194
export default defineEventHandler((event) => {
setResponseHeaders(event, {
"Access-Control-Allow-Methods": "GET,HEAD,PUT,PATCH,POST,DELETE",
"Access-Control-Allow-Origin": "*",
'Access-Control-Allow-Credentials': 'true',
"Access-Control-Allow-Headers": '*',
"Access-Control-Expose-Headers": '*'
})
if(getMethod(event) === 'OPTIONS'){
event.res.statusCode = 204
event.res.statusMessage = "No Content."
return 'OK'
}
})