1
1

More than 1 year has passed since last update.

apache2環境構築に関することのメモ

Last updated at Posted at 2022-01-06

RaspberryPi OS 64bitで確認。

Access-Control-Allow-Origin ヘッダーの追加方法

Access-Control-Allow-Originとは:https://qiita.com/att55/items/2154a8aad8bf1409db2b

from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

ともかくJavascriptからデータをロードする際出てくる上記エラーの対処のためにサーバー側にAccess-Control-Allow-Origin ヘッダー追加する。

$ cd /var/www/html
#htaccessに書く
$ sudo nano .htaccess
Header set Access-Control-Allow-Origin "*"
#apache2のモジュール有効化
$ sudo a2enmod headers
#apache2再起動
$ systemctl restart apache2

参考:https://phaier.github.io/school/engineering/platform/server/apache/how-to/cors.html

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1