{"id":15136305,"url":"https://github.com/thanek/nextcloud-react-app","last_synced_at":"2025-10-23T11:31:19.406Z","repository":{"id":206031792,"uuid":"715660580","full_name":"thanek/nextcloud-react-app","owner":"thanek","description":"Nextcloud file browser written in ReactJS","archived":false,"fork":false,"pushed_at":"2023-11-12T17:16:55.000Z","size":267,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T18:05:24.247Z","etag":null,"topics":["nextcloud","nextcloud-app","reactjs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thanek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-11-07T15:26:19.000Z","updated_at":"2024-07-29T23:27:41.000Z","dependencies_parsed_at":"2023-11-12T18:35:15.855Z","dependency_job_id":null,"html_url":"https://github.com/thanek/nextcloud-react-app","commit_stats":null,"previous_names":["thanek/nextcloud-react-app"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanek%2Fnextcloud-react-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanek%2Fnextcloud-react-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanek%2Fnextcloud-react-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanek%2Fnextcloud-react-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thanek","download_url":"https://codeload.github.com/thanek/nextcloud-react-app/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237821495,"owners_count":19371771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nextcloud","nextcloud-app","reactjs"],"created_at":"2024-09-26T06:20:25.960Z","updated_at":"2025-10-23T11:31:18.825Z","avatar_url":"https://github.com/thanek.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nextcloud file browser APP written in ReactJS\n\nThis is a sketch of the Nextcloud file browser app. You need to modify the Nextcloud server to handle the CORS headers\nproperly.\n\n## Preparing the Nextcloud server to allow CORS requests\n\nYou need to tweak some code in the Nextcloud server instance, because by default it doesn't support the CORS headers,\nwhich are necessary to make requests to Nextcloud from Javascript applications running in the browser.\n\nStep by step, you will need to:\n\n### Allow CORS requests in the Login flow\n\nTo make the Login flow working (allow app users to create their profiles in the app by authenticating via Nextcloud\npage), you need to do the following things:\n\n* introduce new method `preflightedCors` in the class `\\OCP\\AppFramework\\Controller` (located in \n  `lib/public/AppFramework/Controller.php`) which should look like this:\n\n```php\n/**\n * @NoAdminRequired\n * @NoCSRFRequired\n * @PublicPage\n */\npublic function preflightedCors()\n{\n    if (isset($this-\u003erequest-\u003eserver['HTTP_ORIGIN'])) {\n        $origin = $this-\u003erequest-\u003eserver['HTTP_ORIGIN'];\n    } else {\n        $origin = '*';\n    }\n\n    $response = new Response();\n    $response-\u003eaddHeader('Access-Control-Allow-Origin', $origin);\n    $response-\u003eaddHeader('Access-Control-Allow-Methods', '*');\n    $response-\u003eaddHeader('Access-Control-Allow-Headers', '*');\n    $response-\u003eaddHeader('Access-Control-Max-Age', '86400');\n    $response-\u003eaddHeader('Access-Control-Allow-Credentials', 'false');\n    return $response;\n}\n```\n\n* register new route for `OPTIONS` method in the file `core/routes.php`:\n\n```php\n[\n  'name' =\u003e 'ClientFlowLoginV2#preflightedCors', \n  'url' =\u003e '/login/v2{path}',\n  'verb' =\u003e 'OPTIONS', \n  'requirements' =\u003e ['path' =\u003e '.*']\n],\n```\n\n* locate the class file `core/Controller/ClientFlowLoginV2Controller.php`, and:\n* add `@CORS` annotation to the\n  method `\\OC\\Core\\Controller\\ClientFlowLoginV2Controller::public function poll(string $token): JSONResponse`\n* add `@CORS` annotation to the\n  method `\\OC\\Core\\Controller\\ClientFlowLoginV2Controller::public function init(): JSONResponse`\n\n### Allow CORS requests in the webdav files API\n\nOpen the `remote.php` file and find a block that looks like this\n\n```php\nif (\\OCP\\Util::needUpgrade()) {\n    // since the behavior of apps or remotes are unpredictable during\n    // an upgrade, return a 503 directly\n    throw new RemoteException('Service unavailable', 503);\n}\n```\n\nUnder this block, you need to add the following code:\n\n```php\n// Allow from any origin\nif (isset($_SERVER['HTTP_ORIGIN'])) {\n    // Decide if the origin in $_SERVER['HTTP_ORIGIN'] is one\n    // you want to allow, and if so:\n    header(\"Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}\");\n    header('Access-Control-Allow-Credentials: true');\n    header('Access-Control-Max-Age: 86400');    // cache for 1 day\n}\n\n// Access-Control headers are received during OPTIONS requests\nif ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {\n    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))\n        // may also be using PATCH, HEAD etc\n        header(\"Access-Control-Allow-Methods: *\");\n\n    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))\n        header(\"Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}\");\n\n    exit(0);\n}\n```\n\n### Allow CORS requests for thumbnail requests\n\n* In the class `\\OCA\\Files\\Controller\\ApiController` (`apps/files/lib/Controller/ApiController.php`), find the method \n  `public function getThumbnail($x, $y, $file)` and add the `@CORS` annotation to it.\n* Register new route in `apps/files/appinfo/routes.php` by adding the following to the `routes` array declaration:\n\n```php\n[\n    'name' =\u003e 'API#preflightedCors',\n    'url' =\u003e '/api/v1/{path}',\n    'verb' =\u003e 'OPTIONS',\n    'requirements' =\u003e ['path' =\u003e '.*']\n],\n```\n\nAnd that's it. From now on, you should be able to register new profile in the app and browse the Nextcluod content from it!\n\n## Available Scripts\n\nIn the project directory, you can run:\n\n### `npm start`\n\nRuns the app in the development mode.\\\nOpen [http://localhost:3000](http://localhost:3000) to view it in your browser.\n\nThe page will reload when you make changes.\\\nYou may also see any lint errors in the console.\n\n### `npm test`\n\nLaunches the test runner in the interactive watch mode.\\\nSee the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more\ninformation.\n\n### `npm run build`\n\nBuilds the app for production to the `build` folder.\\\nIt correctly bundles React in production mode and optimizes the build for the best performance.\n\nThe build is minified and the filenames include the hashes.\\\nYour app is ready to be deployed!\n\nSee the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.\n\n### `npm run eject`\n\n**Note: this is a one-way operation. Once you `eject`, you can't go back!**\n\nIf you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will\nremove the single build dependency from your project.\n\nInstead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right\ninto your project so you have full control over them. All of the commands except `eject` will still work, but they will\npoint to the copied scripts so you can tweak them. At this point you're on your own.\n\nYou don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you\nshouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't\ncustomize it when you are ready for it.\n\n## Learn More\n\nYou can learn more in\nthe [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).\n\nTo learn React, check out the [React documentation](https://reactjs.org/).\n\n### Code Splitting\n\nThis section has moved\nhere: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)\n\n### Analyzing the Bundle Size\n\nThis section has moved\nhere: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)\n\n### Making a Progressive Web App\n\nThis section has moved\nhere: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)\n\n### Advanced Configuration\n\nThis section has moved\nhere: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)\n\n### Deployment\n\nThis section has moved\nhere: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)\n\n### `npm run build` fails to minify\n\nThis section has moved\nhere: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthanek%2Fnextcloud-react-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthanek%2Fnextcloud-react-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthanek%2Fnextcloud-react-app/lists"}