Getting 403 on sending request laravel
I'm getting a 403 error on uploading some images on specific fields but it's working on other fields. And on some other API, it is giving 403 when I even didn't upload any images. But in those APIs, I send HTML content in the request body.
Here's my validation for validating the image
'image' => 'required|mimes:jpg,jpeg,png,pdf,txt,doc,docx,xls,xlsx,zip|max:35840',
This validation is the same for every image.
Note: I already enabled cors for my all APIs and review many blogs related to this topic.
do you know?
how many words do you know
See also questions close to this topic
-
delete a table form a database using laravel command
i need to delete a database table using laravel artisan command . not like this command php artisan migrate:rollback --step=5
i need to create like this route or controller code .
Route::get('/clear/database', function () {
Artisan::call('cache:clear'); return redirect('/');
});
. i also try public function dd()
{ Schema::drop('table_name'); }
but it not working . gives me error like this SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (SQL: drop table
table_name
)no foreign key for the table . what should i do ?
thanks in advance!
-
Foreach for Categories
i have this data, I want to loop with categories for each question. Right now all I can do is loop by displaying sequentially for each question (as in the image).what I want to do is loop and group them based on categories_id , if the categories_id changes it will be given a new line.
// 20220507095412 // http://127.0.0.1:8000/user/exams [ { "id": 16, "ujians_id": 11, "questions_id": 3, "mulai": null, "berakhir": null, "durasi": 60, "isAnswer": 0, "created_at": "2022-05-07T02:53:56.000000Z", "updated_at": "2022-05-07T02:53:56.000000Z", "questions": { "id": 3, "title": "2", "question": "<p>Sarana yang sangat masih dalam menyebabkan oposisi dunia yang sering berdampak pada intervensi asing terhadap Indonesia pada era globalisasi sekarang ini adalah...</p>", "img": null, "categories_id": 1, "created_at": "2022-05-07T02:11:41.000000Z", "updated_at": "2022-05-07T02:11:41.000000Z" } }, { "id": 17, "ujians_id": 11, "questions_id": 1, "mulai": null, "berakhir": null, "durasi": 60, "isAnswer": 0, "created_at": "2022-05-07T02:53:56.000000Z", "updated_at": "2022-05-07T02:53:56.000000Z", "questions": { "id": 1, "title": "13", "question": "<p>Wahidin soedirohoesodo memilik peran penting dalam pergerakan kemerdekaan. Antara lain…22234232</p>", "img": null, "categories_id": 1, "created_at": "2022-05-02T10:39:13.000000Z", "updated_at": "2022-05-03T13:28:24.000000Z" } } ]
@php $no=1 @endphp @foreach($dataUjian as $row) @if($row->isAnswer == 0) <button class="btn btn-primary btn-sm" onclick="getUjian({{$row->questions_id}}, {{$row->id}},{{$row->ujians->users_id}})" >{{$no++}}</button> @else <button class="btn btn-danger btn-sm" disabled>{{$no++}}</button> @endif @endforeach
-
Unit testing with get request
I am trying to create a unit test for one of my api.
In the frontend, I send it this way...
params = { participants: JSON.stringify(participants), section: JSON.stringify(section), }; axios.get('/api/list', params)
while in the controller, it receives the params this way...
public function list(Request $request) { $participants = json_decode($request->participants); $section = json_decode($request->section); }
Now, I tried making a unit test out of this. by doing...
$params = [ 'participants' => ['id', 'name', 'rating'], 'section' => ['id', 'code'], ]; $this->get('/api/list'.http_build_query($params))->assertStatus(200) // $this->json('/api/list', $params)->assertStatus(200) // -> also tried this one // $this->getJson('/api/list', $params)->assertStatus(200) // -> also tried this one // $this->call('GET', '/api/list', $params)->assertStatus(200) // -> also tried this one
But none of them works, it always says
TypeError: json_decode(): Argument #1 ($json) must be of type string, array given
.So, the way I built the url and the params must be all wrong,
so my question here is that, what's the correct way of building the url so that it provides a correct url string format and the controller will json_decode the params?
-
Images with Firebase and Python Flask API
I am currently developing an API using Firebase from google and Python's Flask libraries. It is a proyect where I am in need of saving images to the DB and then adress them in the API. I would also like to know how to relate the image to an item in the database, say posting an image of Juan, and that is linked with ALL the information from Juan inside the DB. Thanks!
-
Need help finding an api or real world data related to read time of people
I need to create a project for which I require real world data of reading time per page or article. Can anyone help me find data or api in which I can get this data I tried to search for some api but they had information related to books instead of their reading time of a person.
-
Using Websocket Channel in React
I am working on a project where I have to make an api call to a websocket, and display certain information based on that call. As you can see I have used the subscribe portion of the channel in my call. Now I'm not sure what to do if anything with the 2nd two set of bracket. Do I need to include them my call as well, or do they come along with the subscription? And from which of them would I be using the information I need to display? In other words which one is the information I am recieving?
'''
const ws = new WebSocket("wss://ws-feed.exchange.coinbase.com"); const apiCall = { type: "subscribe", product_ids: [ "ETH-USD", "BTC-USD" ], channels: ["level2"] }; ws.onopen = (event) => { ws.send(JSON.stringify(apiCall)); }; ws.onmessage = function (event) { const json = JSON.parse(event.data); console.log(`[message] Data received from server: ${json}`); };
'''
-
403 Forbidden on initial load after installing NextCloudPi
I am making this post mostly for awareness in case anyone else is having a similar issue.
Story
I am running nextcloudpi (nextcloudpi.ownyourbits.com) on a Raspberry Pi 4 8GB using the Debian Buster install script. Note: the OS is Raspberry Pi OS Bullseye 64bit. The install would succeed and tell me to navigate to
https://<rpi_ip>/
orhttps://raspberrypi/
etc. As soon as I did that it would immediately return with a 403 Forbidden. I looked all over and everyone kept pointing to the "trusted_domains" config or the "trusted_proxy", basically trying to use the config file to fix the problem. However, I came to realize that the issue did not lie with the nextcloudpi (ncp) install but rather with apache2.Well, I reinstalled Raspberry Pi OS and then installed nextcloudpi again fresh. Then, before navigating to
https://<rpi_ip>/
I instead went to go check out the activation script located at/etc/apache2/sites-enabled/ncp-activation.conf
There is where I found this code block:<RequireAny> Require host localhost Require local Require ip 192.168 Require ip 172 Require ip 10 ... </RequireAny>
I now could see that my issue lied with this because my ip address pool did not start with 192.169, or 172, or 10. I had made my ip addresses custom for this virtual network and therefore the activation script would never work. All I had to do was add:
<RequireAny> Require host localhost Require local Require ip 192.168 Require ip 172 Require ip 10 Require ip 123 ... </RequireAny>
After that, the activation worked and I was able to get the initial passwords for the account and continue the initial setup.
tl;dr
Problem
- Initial load after installing NextCloudPi resulted in 403 because the IP address of the nextcloudpi install was custom and did not start with
192.168
,172
, or10
.
Solution
- After installation completes, open
/etc/apache2/sites-enabled/ncp-activation.conf
and add the first octet of the custom IP address, or you can tighten the scope by adding the second and third octets too.
I.e ->
<RequireAny> Require host localhost Require local Require ip 192.168 Require ip 172 Require ip 10 # Add this line but change 123 to your custom ip pool's first octet Require ip 123 # Or this to tighten scope of the ip range Require ip 111.222.333 ... </RequireAny>
Initial findings that pointed me in this direction : https://github.com/nextcloud/nextcloudpi/issues/408#issuecomment-365589838
NextCloudPi : https://ownyourbits.com/nextcloudpi/#content_start
- Initial load after installing NextCloudPi resulted in 403 because the IP address of the nextcloudpi install was custom and did not start with
-
Htaccess URL rewrite with get parameters
so I've recently changed my website's file structure a little bit and now need to redirect my old URLs to the new ones.
This is what the old URLs looked like:
example.com/script?id=1&title=TitleHere
the script.php is now in a sub-folder with the name "script", so the new URL is:
example.com/script/1/TitleHere
(This one is already working, but I still need my old urls to redirect to this pattern.)This is what I tried in my htaccess:
RewriteRule ^script?id=([0-9]+)&title=(.*) /script/$2-$1 [L,R=301]
Not sure if this is of importance but I am also using these htaccess settings:
Options -Indexes RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^(.*)$ $1.html [NC,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php [NC,L]
Sadly my attempt didn't bring me any success, it's just throwing a 403 and I think that's because a folder named "script" already exists but I am not sure. Help would be highly appreciated!
-
Bad Twitter streaming request: 403
I'm trying to access twitter's api v1.1 filtered streaming endpoint but it gives me 403 error. I don't understand why. I can access other endpoints but not filtered stream for some reason.
It gives me this error-
HTTP ERROR: 403
Problem accessing '/1.1/statuses/filter.json
Reason: Please use V2 filtered and sample volume stream as alternatives