Skip to content

关于跨域问题 #222

Answered by surmon-china
ChenXuyuan97 asked this question in Q&A
Jun 30, 2022 · 2 comments · 9 replies
Discussion options

You must be logged in to vote
  1. api.surmon.menodepress 的生产环境运行时,是做了防盗链处理的,任何非 surmon.me 域名访问都应该被拒绝访问
  2. spa:dev 启动的是基于 vite 的开发服务器,其内部做了 proxy 处理
  3. spa:start 是 vite 将源码 bundle 后启动了一个基于 http-server 的静态 HTTP 服务器,你可以理解为一个干净无副作用的 web server,由于这时是没有 proxy 层的,所以 localhost 访问 api.surmon.me 一定会跨域报错

换言之,“跨域错误” 是符合预期的,你应该在本地 clone nodepress 项目,并启用你本地的 nodepress API server 服务,运行完整的一套 blog 应用。

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
9 replies
@ChenXuyuan97
Comment options

@surmon-china
Comment options

@ChenXuyuan97
Comment options

@surmon-china
Comment options

@ChenXuyuan97
Comment options

Answer selected by surmon-china
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants