Building ‘photo-gallery’ with the help of ‘Build your first app’ in Ionic docs. Getting a 504 and the following error when I click the ‘photo’ icon and try to take a photo:
Loading module from “http://localhost:8100/node_modules/.vite/deps/pwa-camera-modal.entry.js” was blocked because of a disallowed MIME type (“”).
I have checked via the terminal and although both /vite and /.vite exist and have seemingly been installed, /node_modules/.vite/deps/pwa-camera-modal.entry.js does not exist (maybe because it’s dynamic?) so it looks like the hook is calling the correct file but is failing. The app was working fine up to the point of testing the photo function.
Here is the hook:
import { useState, useEffect } from 'react';
import { isPlatform } from '@ionic/react';
import { Camera, CameraResultType, CameraSource, Photo } from '@capacitor/camera';
import { Filesystem, Directory } from '@capacitor/filesystem';
import { Preferences } from '@capacitor/preferences';
import { Capacitor } from '@capacitor/core';
export function usePhotoGallery() {
const takePhoto = async () => {
const photo = await Camera.getPhoto({
resultType: CameraResultType.Uri,
source: CameraSource.Camera,
quality: 100,
});
};
return {
takePhoto,
};
}
Here is my package.json file so you can see my versions.
{
"name": "photo-gallery",
"private": true,
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"test.e2e": "cypress run",
"test.unit": "vitest",
"lint": "eslint"
},
"dependencies": {
"@capacitor/app": "5.0.2",
"@capacitor/camera": "^5.0.2",
"@capacitor/core": "5.0.3",
"@capacitor/filesystem": "^5.0.2",
"@capacitor/haptics": "5.0.2",
"@capacitor/keyboard": "5.0.2",
"@capacitor/preferences": "^5.0.2",
"@capacitor/status-bar": "5.0.2",
"@ionic/pwa-elements": "^3.1.1",
"@ionic/react": "^7.0.0",
"@ionic/react-router": "^7.0.0",
"@types/react-router": "^5.1.20",
"@types/react-router-dom": "^5.3.3",
"ionicons": "^7.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router": "^5.3.4",
"react-router-dom": "^5.3.4"
},
"devDependencies": {
"@capacitor/cli": "5.0.3",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@vitejs/plugin-legacy": "^4.0.2",
"@vitejs/plugin-react": "^3.1.0",
"cypress": "^12.7.0",
"eslint": "^8.35.0",
"eslint-plugin-react": "^7.32.2",
"jsdom": "^21.1.0",
"typescript": "^4.9.3",
"vite": "^4.1.0",
"vitest": "^0.29.2"
},
"description": "An Ionic project"
}
Please help, really looking forward to see what ionic can do :) Just ask if you need any other info from my system. I'm developing on a Linux Mint OS
thanks,
Mike